根据我的规律,每天solved3题就感觉不行了~但是今天好像做水题做上瘾了,不过PC的题目尽管水,水得还是可以让人有进步。
这题OJ自动测评真心坑,题目看起来十分简单,测评返回三种可能:
Accepted
Wrong Answer
Presentation Error
当输出字符完全相等,就是AC
当输出的数字字符按序相等,就是PE,
否则就是WA
坑爹就是坑在这个PE问题。
比如
3
1
1
1
1
111
这是PE的答案。。。不能仅仅是按行来比较,所以我,直接就拼在一个字符串了~当然,不拼也是很简单的。
/*******************************************************************************/ /* OS : 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 UTC 2013 GNU/Linux * Compiler : g++ (GCC) 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) * Encoding : UTF8 * Date : 2014-03-30 * All Rights Reserved by yaolong. *****************************************************************************/ /* Description: *************************************************************** *****************************************************************************/ /* Analysis: ****************************************************************** *****************************************************************************/ /*****************************************************************************/ #include<iostream> #include<cstdio> #include<cstring> #include<vector> #include<stack> using namespace std; #define AC 0 #define WA 1 #define PE 2 void fun(int a,int cases) { switch(a) { case AC: cout<<"Run #"<<cases<<": Accepted"<<endl; break; case PE: cout<<"Run #"<<cases<<": Presentation Error"<<endl; break; case WA: cout<<"Run #"<<cases<<": Wrong Answer"<<endl; break; } } bool isPE(string str1,string str2) { int i,flag=1; int len1=str1.length(),len2=str2.length(); stack<int> stk1,stk2; for(i=0; i<len1; i++) if(str1[i]>='0'&&str1[i]<='9') { stk1.push(str1[i]-'0'); } for(i=0; i<len2; i++) if(str2[i]>='0'&&str2[i]<='9') { stk2.push(str2[i]-'0'); } if(stk1.size()!=stk2.size())return 0; while(!stk1.empty()) { if(stk1.top()!=stk2.top()) flag=0; stk1.pop(); stk2.pop(); } return flag; } int main() { int n,i,m; int cases=0; vector<string> v_ans,v_sub; while(cin>>n&&n) { cases++; v_ans.clear(); v_sub.clear(); v_ans.resize(n); getchar(); for(i=0; i<n; i++) { getline(cin,v_ans[i]); } cin>>m; getchar(); v_sub.resize(m); for(i=0; i<m; i++) { getline(cin,v_sub[i]); } int nmin=n>m?m:n; //取数据最少比较 int nmax=n>m?n:m; v_sub.resize(nmax); v_ans.resize(nmax); for(i=0; i<nmin; i++) //AC { if(v_ans[i]!=v_sub[i]) { break; } } if(i==nmin&&m==n) { fun(AC,cases); continue; } string tmp_a="",tmp_b=""; for(i=0; i<nmax; i++){ tmp_a=tmp_a+v_ans[i]; } for(i=0; i<nmax;i++){ tmp_b=tmp_b+v_sub[i]; } if(isPE(tmp_a,tmp_b)) { fun(PE,cases); continue; } fun(WA,cases); } return 0; }
2 The answer is: 10 The answer is: 5 2 The answer is: 10 The answer is: 5 2 The answer is: 10 The answer is: 5 2 The answer is: 10 The answer is: 15 2 The answer is: 10 The answer is: 5 2 The answer is: 10 The answer is: 5 3 Input Set #1: YES Input Set #2: NO Input Set #3: NO 3 Input Set #0: YES Input Set #1: NO Input Set #2: NO 1 1 0 1 0 1 1010 1 The judges are mean! 1 The judges are good! 1 asd 1 asd 3 11 11 11 1 111111 3 11 12 13 4 11 12 13 14 3 11 12 13 4 11 1 2 13 0