九度OJ 1009

来源:互联网 发布:群硕软件 编辑:程序博客网 时间:2024/05/24 23:12
#include <iostream>#include <string>using namespace std;int main(){    int n;    while(cin >> n, n != 0)    {        string tree;        cin >> tree;        string root;        root = tree[0];        string left;        string right;        for(int i = 1; i < tree.size(); ++i)        {            if(tree[i] > tree[0])                right += tree[i];            else                left += tree[i];        }        for(int i = 0; i < n; ++i)        {            string temp;            cin >> temp;            string a, b, r;            r = temp[0];            for(int i = 1; i < temp.size(); ++i)            {                if(temp[i] > temp[0])                    a += temp[i];                else                    b += temp[i];            }            if(a == right && b == left && r == root)                cout << "YES" << endl;            else                cout << "NO" << endl;        }    }}

0 0
原创粉丝点击