#include <stdio.h>
#include <string.h>
#include <set>
#include <vector>
using namespace std;
vector<int> t(26);
set<vector<int> > s;
char a[1510],b[1510];
int main(){
int i,j,n,m;
scanf("%s\n%s",a,b);
n=strlen(a);
m=strlen(b);
for(i=min(n,m);i;--i){
for(j=0;j<26;++j)t[j]=0;
for(j=0;j<i-1;++j)++t[a[j]-97];
for(j=i-1;j<n;++j){
++t[a[j]-97];
s.insert(t);
--t[a[j-i+1]-97];
}
for(j=0;j<26;++j)t[j]=0;
for(j=0;j<i-1;++j)++t[b[j]-97];
for(j=i-1;j<m;++j){
++t[b[j]-97];
if(s.find(t)!=s.end()){
printf("%d",i);
return 0;
}
--t[b[j-i+1]-97];
}
s.clear();
}
puts("0");
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1584 KB |
Output is correct |
2 |
Correct |
0 ms |
1584 KB |
Output is correct |
3 |
Correct |
0 ms |
1584 KB |
Output is correct |
4 |
Correct |
2 ms |
1584 KB |
Output is correct |
5 |
Correct |
0 ms |
1584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
1584 KB |
Output is correct |
2 |
Correct |
29 ms |
1584 KB |
Output is correct |
3 |
Correct |
0 ms |
1584 KB |
Output is correct |
4 |
Correct |
0 ms |
1584 KB |
Output is correct |
5 |
Correct |
50 ms |
1584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
209 ms |
1716 KB |
Output is correct |
2 |
Correct |
229 ms |
1716 KB |
Output is correct |
3 |
Correct |
220 ms |
1716 KB |
Output is correct |
4 |
Correct |
214 ms |
1716 KB |
Output is correct |
5 |
Correct |
222 ms |
1716 KB |
Output is correct |
6 |
Correct |
217 ms |
1716 KB |
Output is correct |
7 |
Correct |
220 ms |
1716 KB |
Output is correct |
8 |
Correct |
215 ms |
1716 KB |
Output is correct |
9 |
Correct |
224 ms |
1716 KB |
Output is correct |
10 |
Correct |
222 ms |
1716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
1584 KB |
Output is correct |
2 |
Correct |
417 ms |
1716 KB |
Output is correct |
3 |
Correct |
363 ms |
1716 KB |
Output is correct |
4 |
Correct |
13 ms |
1584 KB |
Output is correct |
5 |
Correct |
516 ms |
1716 KB |
Output is correct |