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<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
string A,B;
set<vector<int>> S;
int main()
{
cin>>A>>B;
for(int i=min(A.size(),B.size());i>=1;i--)
{
S.clear();
vector<int> p(26,0);
for(int j=0;j<i;j++)
p[A[j]-'a']++;
S.insert(p);
for(int j=i;j<A.size();j++)
{
p[A[j-i]-'a']--;
p[A[j]-'a']++;
S.insert(p);
}
vector<int> q(26,0);
for(int j=0;j<i;j++)
q[B[j]-'a']++;
if(S.find(q)!=S.end()){ cout<<i; return 0; }
for(int j=i;j<B.size();j++)
{
q[B[j-i]-'a']--;
q[B[j]-'a']++;
if(S.find(q)!=S.end()){ cout<<i; return 0; }
}
}
cout<<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... |