This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |