-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1506C.cpp
More file actions
40 lines (37 loc) · 762 Bytes
/
1506C.cpp
File metadata and controls
40 lines (37 loc) · 762 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
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
cin.tie(0);
ios::sync_with_stdio(0);
int t;
cin >> t;
while (t--)
{
string a,b;cin>>a>>b;
int n = a.find(b);
int ind=0;
int b_s=b.size();
int a_s=a.size();
while(n==-1 && ind<b_s) {
for(int i=0;i<=ind;i++) {
n=a.find(b.substr(i,b_s-ind));
if(n!=-1) {
break;
}
}
if(n!=-1) {
break;
}
ind++;
}
if(n!=-1) {
cout<<ind+(a.size()-b_s+ind)<<'\n';
}
else {
cout << b_s+a_s << '\n';
}
}
return 0;
}