-
Notifications
You must be signed in to change notification settings - Fork 1
/
C.cpp
41 lines (29 loc) · 882 Bytes
/
C.cpp
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
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string a,b;
int t,la,lb,maxn;
int main(){
cin>>t;
while(t--){
cin>>a>>b;
maxn = 0;
la = a.length(),lb = b.length();
for(int l = 1;l <= la && l <= lb;++l){
for(int i = 0;i < la - l + 1;++i){
for(int j = 0;j < lb - l + 1;++j){
bool flag = true;
for(int notea = i,noteb = j;notea <= i + l - 1;++notea,++noteb)
if(a[notea] != b[noteb]){
flag = false;break;
}
if(flag)
maxn = max(maxn,l);
}
}
}
cout<<la + lb - maxn * 2<<"\n";
}
return 0;
}