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 <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int n,m,res;
char arr1[1510],arr2[1510];
vector<int> vt(26);
set <vector <int> > st;
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']++; st.insert(vt);
for(;i<n;i++){
vt[arr1[i]-'a']++; vt[arr1[i-a]-'a']--; st.insert(vt);
}
}
void iscan(int a){
int i;
for(i=0;i<a;i++) vt[arr2[i]-'a']++; if(st.find(vt)!=st.end()){ res=a; return; }
for(;i<m;i++){
vt[arr2[i]-'a']++; vt[arr2[i-a]-'a']--;
if(st.find(vt)!=st.end()){ 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();
st.clear();
}
printf("%d",res);
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... |