-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1881A.cpp
More file actions
56 lines (44 loc) · 1.01 KB
/
1881A.cpp
File metadata and controls
56 lines (44 loc) · 1.01 KB
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
53
54
55
56
#include <bits/stdc++.h>
using namespace std;
bool check(string s, string x){
if (x.size() < s.size())
return false;
for (int i = 0; i < x.size() - s.size() + 1; i++){
if (x.substr(i,s.size()) == s)
return true;
}
return false;
}
int main(){
int t;
cin >> t;
while (t--){
long long n, m;
cin >> n >> m;
string x;
cin >> x;
string s;
cin >> s;
string x0 = x;
string x1 = x0 + x0;
string x2 = x1 + x1;
string x3 = x2 + x2;
string x4 = x3 + x3;
string x5 = x4 + x4;
long long ans = -1;
if (check(s,x0))
ans = 0;
else if (check(s,x1))
ans = 1;
else if (check(s,x2))
ans = 2;
else if (check(s,x3))
ans = 3;
else if (check(s,x4))
ans = 4;
else if (check(s,x5))
ans = 5;
cout << ans << endl;
}
return 0;
}