题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1073
解题报告:字符串处理题,判断WA 好判断,AC也好判断,判断PE就是如果判断出来不是AC的话就把输入跟输出字符中的所有空格跟tab字符去掉再判断,如果去掉之后完全相同的话,那就说明是PE,否则就是WA。
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 using namespace std; 5 6 char *ans[5005],*res[5005]; 7 char str[5000],s[5005]; 8 int len_a,len_r; 9 10 void hehe(char *ss,char *temp[5005],int len) 11 { 12 char p[10] = " "; 13 int f = 0; 14 for(int i = 0;i < len;++i) 15 { 16 int l = strlen(temp[i]); 17 for(int j = 0;j < l;++j) 18 if(temp[i][j] != ' ' && temp[i][j] != p[0]) 19 ss[f++] = temp[i][j]; 20 } 21 ss[f] = NULL; 22 } 23 24 void clean(char *temp[5005],int len) 25 { 26 for(int i = 0;i < len;++i) 27 delete temp[i]; 28 } 29 30 int main() 31 { 32 33 int T; 34 scanf("%d",&T); 35 while(T--) 36 { 37 len_a = len_r = 0; 38 getchar(); 39 gets(str); 40 gets(str); 41 while(strcmp(str,"END")) 42 { 43 int len = strlen(str); 44 ans[len_a] = new char[len+5]; 45 strcpy(ans[len_a++],str); 46 gets(str); 47 } 48 int flag = 1; 49 gets(str); 50 gets(str); 51 while(strcmp(str,"END")) 52 { 53 int len = strlen(str); 54 res[len_r] = new char[len+5]; 55 strcpy(res[len_r++] , str); 56 if(len_r <= len_a && strcmp(res[len_r-1],ans[len_r-1])) flag = 2; 57 gets(str); 58 } 59 if(flag == 1 && len_a == len_r) 60 { 61 printf("Accepted "); 62 clean(ans,len_a); 63 clean(res,len_r); 64 continue; 65 } 66 hehe(str,ans,len_a); 67 hehe(s,res,len_r); 68 printf(strcmp(str,s)? "Wrong Answer ":"Presentation Error "); 69 clean(ans,len_a); 70 clean(res,len_r); 71 } 72 return 0; 73 }