#includeusing namespace std;int main() {\tchar a[100][100], b[100][100]; \tstring c[100];\tstring tmp;\tint n, i = 0, j = 0, k = 0, total_len[100], length[100][3];\t\tcin >> n; \t\tgetline(cin, tmp);\t\tfor (i = 0; i < n; i ) { \t\t\tgetline(cin, c[i]);\t\t\ttotal_len[i] = c[i].size();\t\t}\t\tfor (i = 0; i < n; i ) {\t\t\tj = 0;\t\t\twhile (c[i][j] != ':') { \t\t\t\ta[i][k] = c[i][j];\t\t\t\tk = k 1; \t\t\t\tj ;\t\t\t}\t\t\tlength[i][1] = k - 1; \t\t\ta[i][k] = 0;\t\t\tk = 0;\t\t\tfor (j = j 1; j < total_len[i]; j ) { \t\t\t\tb[i][k] = c[i][j];\t\t\t\tk = k 1;\t\t\t}\t\t\tlength[i][2] = k - 1; \t\t\tb[i][k] = 0;\t\t\tk = 0;\t\t}\t\tfor (i = 0; i < n; i ) {\t\t\tif (length[i][1] >= length[i][2]) \t\t\t\tcout << "NO,";\t\t\telse {\t\t\t\tk = 0;\t\t\t\tfor (j = 0; j < length[i][2]; j ) { \t\t\t\t\tif (a[i][k] == b[i][j])\t\t\t\t\t\tk = k 1;\t\t\t\t\tif (k > length[i][1]) \t\t\t\t\t\tbreak;\t\t\t\t}\t\t\t\tif (j == length[i][2]) \t\t\t\t\tcout << "NO,";\t\t\t\telse\t\t\t\t\tcout << "YES,";\t\t\t}\t}\tcout << endl;\treturn 0;}
输入:
3
AB:ACDEbFBkBD
AR:ACDBrT
SARS:Severe Atypical Respiratory Syndrome
输出:
(注:输入各行前后均无空格)
发表评论 取消回复