Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求高手指教,给出的测试都过,不超时 就是WA#include<iostream> #include<string> #include<vector> #include<math.h> using namespace std; vector<string> ss; int find(vector<string> vv,string cmp) { int n = vv.size(); for(int i=0;i<n;i++) { if(vv[i] == cmp) { return i; } } return 10000001; } string cmp(string str,string cmp) { int len1 = str.length(); int len2 = cmp.length(); int i; int test = len1 - len2; if(abs(test) > 1) return "%%"; int cnt; if(test == 0) { cnt =0; for(i=0;i<len1;i++) { if(str[i] != cmp[i]) {cnt++;} } if(cnt == 1) return cmp; } if(test > 0) { cnt = 0; for(i=0;i<len1;i++) { if(cmp.find(str[i]) < 10000)cnt++; } if(cnt == len2) return cmp; } if(test < 0) { cnt = 0; for(i=0;i<len1;i++) { if(cmp.find(str[i]) < 10000)cnt++; } if(cnt == len1) return cmp; } return "%%"; } int main() { //ifstream cin("test.txt"); string strin,strtp; vector<string>::iterator it; while(cin>>strin && strin != "#") { ss.insert(ss.end(),strin); } while(cin>>strin && strin != "#") { if(find(ss,strin) < 10000000) { cout<<strin<<" is correct\n"; } else { cout<<strin<<":"; for(it = ss.begin();it!=ss.end();it++) { strtp = cmp(strin,*it); if(strtp != "%%") { cout<<" "<<strtp; } } cout<<"\n"; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator