非常简单的字符串匹配,懒得又读取又切割,于是就用了一个懒一点的方法直接比较了
/* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <queue> #define INF 1E9 using namespace std; char text[2][5010]; int n[2]; void input(int num) { n[num]=0; while(text[num][n[num]++]=getchar()) { if(text[num][n[num]-1]=='D'&&text[num][n[num]-2]=='N'&&text[num][n[num]-3]=='E'&&text[num][n[num]-4]=='\n')break; } getchar(); } bool check(char t) { return t==' '||t=='\t'||t=='\n'; } int main() { int flag; int T; scanf("%d",&T); getchar(); while(T--) { flag=0; input(0); input(1); int i,j; for(i=j=0;i<n[0]||j<n[1];) { if(text[0][i]==text[1][j]){i++;j++;} else if(check((text[0][i]))) { flag=1;i++;continue; } else if(check(text[1][j])) { flag=1;j++;continue; } else { flag=-1;break; } } switch(flag) { case 0:printf("Accepted\n");break; case 1:printf("Presentation Error\n");break; case -1:printf("Wrong Answer\n");break; } } }
时间: 2024-10-29 23:34:11