#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int n,m,res;
char arr1[1510],arr2[1510];
vector<int> vt(26);
map <vector <int> ,bool> mp;
void vector_init(){
int i;
for(i=0;i<26;i++) vt[i]=0;
}
void init(int a){
int i;
for(i=0;i<a;i++) vt[arr1[i]-'a']++; mp[vt]=1;
for(;i<n;i++){
vt[arr1[i]-'a']++; vt[arr1[i-a]-'a']--; mp[vt]=1;
}
}
void iscan(int a){
int i;
for(i=0;i<a;i++) vt[arr2[i]-'a']++; if(mp[vt]==1){ res=a; return; }
for(;i<m;i++){
vt[arr2[i]-'a']++; vt[arr2[i-a]-'a']--;
if(mp[vt]==1){ res=a; return; }
}
}
int main(){
int i,j;
scanf("%s %s",arr1,arr2); n=strlen(arr1); m=strlen(arr2);
for(i=1;i<=min(n,m);i++){
init(i); vector_init();
iscan(i); vector_init();
if(i<500) mp.clear();
}
printf("%d",res);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1588 KB |
Output is correct |
2 |
Correct |
0 ms |
1588 KB |
Output is correct |
3 |
Correct |
1 ms |
1588 KB |
Output is correct |
4 |
Correct |
2 ms |
1588 KB |
Output is correct |
5 |
Correct |
4 ms |
1588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
93 ms |
1720 KB |
Output is correct |
2 |
Correct |
64 ms |
1588 KB |
Output is correct |
3 |
Correct |
15 ms |
1588 KB |
Output is correct |
4 |
Correct |
11 ms |
1588 KB |
Output is correct |
5 |
Correct |
102 ms |
1720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
542 ms |
45016 KB |
Output is correct |
2 |
Correct |
606 ms |
46468 KB |
Output is correct |
3 |
Correct |
581 ms |
46072 KB |
Output is correct |
4 |
Correct |
552 ms |
45016 KB |
Output is correct |
5 |
Correct |
579 ms |
46468 KB |
Output is correct |
6 |
Correct |
554 ms |
45280 KB |
Output is correct |
7 |
Correct |
581 ms |
46468 KB |
Output is correct |
8 |
Correct |
585 ms |
46600 KB |
Output is correct |
9 |
Correct |
600 ms |
46600 KB |
Output is correct |
10 |
Correct |
594 ms |
46336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
244 ms |
24424 KB |
Output is correct |
2 |
Execution timed out |
1000 ms |
131072 KB |
Program timed out |
3 |
Halted |
0 ms |
0 KB |
- |