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 |
why WA?help me please#include <iostream> #include <string> using namespace std; int main() { int nCases,n,c = 1; cin >> nCases; string str1,str2,str,tar_str; while(c <= nCases) { cin >> n; cin >> str1; cin >> str2; cin >> tar_str; int i,count = 0; str = str.erase(0,str.size()); for(i = 0;i < n;i++) { str.append(1,str2.at(i)); str.append(1,str1.at(i)); } //cout << str << endl; count++; string tmp1,tmp2; while(str.compare(tar_str) != 0) { tmp1 = str.substr(0,n); tmp2 = str.substr(n,n); //cout << "***" << tmp1 << " " << tmp2 <<endl; if(tmp1.compare(str2) == 0 && tmp2.compare(str1) == 0) { count = -1; break; } str = str.erase(0,str.size()); for(i = 0;i < n;i++) { str.append(1,tmp1.at(i)); str.append(1,tmp2.at(i)); } //cout << str << endl; count++; } cout << c << " " << count << endl; count = 0; tmp1.erase(0,tmp1.size()); tmp2.erase(0,tmp2.size()); c++; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator