#include<iostream>
#include<set>
using namespace std;
typedef long long LL;
set<LL>S;
char A[9999],B[9999];
LL Al,Bl,i,j,k;
LL H[30];
int main()
{
for(i=0,k=1;i<26;i++,k*=(i+2))
H[i]=k;
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>A>>B;
for(Al=0;A[Al];Al++);
for(Bl=0;B[Bl];Bl++);
for(i=min(Al,Bl);i>0;i--)
{
S.clear();
k=0;
for(j=0;j<i;j++)
k+=H[A[j]-97];
S.insert(k);
for(j=0;j<Al-i;j++)
{
k+=H[A[j+i]-97]-H[A[j]-97];
S.insert(k);
}
k=0;
for(j=0;j<i;j++)
k+=H[B[j]-97];
if(S.find(k)!=S.end())
{
cout<<i<<endl;
return 0;
}
for(j=0;j<Bl-i;j++)
{
k+=H[B[j+i]-97]-H[B[j]-97];
if(S.find(k)!=S.end())
{
cout<<i<<endl;
return 0;
}
}
}
cout<<0<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
436 KB |
Output is correct |
2 |
Incorrect |
5 ms |
436 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
95 ms |
728 KB |
Output is correct |
2 |
Correct |
112 ms |
728 KB |
Output is correct |
3 |
Correct |
97 ms |
728 KB |
Output is correct |
4 |
Correct |
85 ms |
768 KB |
Output is correct |
5 |
Correct |
99 ms |
768 KB |
Output is correct |
6 |
Correct |
80 ms |
776 KB |
Output is correct |
7 |
Correct |
129 ms |
776 KB |
Output is correct |
8 |
Correct |
124 ms |
776 KB |
Output is correct |
9 |
Correct |
111 ms |
776 KB |
Output is correct |
10 |
Correct |
103 ms |
776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
776 KB |
Output is correct |
2 |
Incorrect |
159 ms |
776 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |