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 |
0ms AC#include<iostream> #include<stdio.h> #include<vector> #include<map> #include<cstring> #include<cstdlib> #include<algorithm> #include<set> #include<cmath> using namespace std; int main() { ios::sync_with_stdio(false); int n,c; cin >> n; string s1,s2,os1,os2; string des; int k = 0; while(n--){ cin >> c; cin >> os1 >> os2; cin >> des; s1 = os1;s2 = os2; int cnt = 0; bool flag = false; while(true){ string tmp = ""; for(int i = 0; i < c; ++i){ tmp += s2[i]; tmp += s1[i]; } ++cnt; if(tmp == des){ flag = true; break; } // cout << tmp <<endl; s1 = tmp.substr(0,c); s2 = tmp.substr(c,c); // cout << s1 << " "<< s2 <<endl; if(s1 == os1 && s2 == os2){ break; } } if(flag){ cout << ++k << " "<< cnt << endl; } else{ cout << ++k <<" " <<-1 << endl; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator