-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP178PROG.cpp
More file actions
52 lines (47 loc) · 910 Bytes
/
P178PROG.cpp
File metadata and controls
52 lines (47 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<bits/stdc++.h>
using namespace std;
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Ford(i, a, b) for(int i = a; i >= b; i--)
#define ll long long
#define here cout<<"I am Here"<<endl;
int const maxn = 1000000;
int const base = 1e9 + 7;
int main(void){
while(1){
int N;
cin>>N;
if(N == 0) return 0;
string S1, S2;
cin>>S1>>S2;
string X1 = S1, X2 = S2;
string M;
cin>>M;
string S = "";
int res = 0;
while(1){
S = "";
res++;
For(i, 0, N - 1){
S += X2[i];
S += X1[i];
}
if(S == M){
cout<<res<<endl;
break;
}
X1 = "";
X2 = "";
For(i, 0, N - 1){
X1 += S[i];
}
For(i, N, S.length() - 1){
X2 += S[i];
}
if(X1 == S1 && X2 == S2){
cout<<"-1"<<endl;
break;
}
}
}
return 0;
}