# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51643 | okaybody10 | 구간 성분 (KOI15_interval) | C++98 | 0 ms | 0 KiB |
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 <vector>
#include <set>
#pragma GCC optimize(Ofast)
using namespace std;
typedef vector<int> vi;
set<vi> gg;
int main()
{
char s1[1605],s2[1605];
scanf("%s %s",s1,s2);
int l1=strlen(s1),l2=strlen(s2);
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.find(alpha) != gg.end()) { return !printf("%d",i);}
if(++e<l2) alpha[s2[e]-'a']++,alpha[s2[s++]-'a']--;
}
}
printf("0");
return 0;
}