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 <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
set<vi> gg;
int main()
{
string s1,s2; cin>>s1>>s2;
int l1=s1.size(),l2=s2.size();
for(int i=l1;i>0;i--)
{
vi alpha(26);
int s=0,e=i-1;
for(int j=s;j<=e;j++) alpha[s1[j]-'a']++;
while(e<l1)
{
gg.insert(alpha);
if(++e<l1) alpha[s1[e]-'a']++,alpha[s1[s++]-'a']--;
}
}
for(int i=l2;i>0;i--)
{
vi alpha(26);
int s=0,e=i-1;
for(int j=s;j<=e;j++) alpha[s2[j]-'a']++;
while(e<l2)
{
if(gg.count(alpha)) return !printf("%d",i);
if(++e<l2) alpha[s2[e]-'a']++,alpha[s2[s++]-'a']--;
}
}
return !printf("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... |