#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.find(alpha)!=gg.end()) return !printf("%d",i);
if(++e<l2) alpha[s2[e]-'a']++,alpha[s2[s++]-'a']--;
}
}
return !printf("0");
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
3 ms |
616 KB |
Output is correct |
3 |
Correct |
5 ms |
616 KB |
Output is correct |
4 |
Correct |
6 ms |
1288 KB |
Output is correct |
5 |
Correct |
5 ms |
1288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
83 ms |
13548 KB |
Output is correct |
2 |
Correct |
95 ms |
17132 KB |
Output is correct |
3 |
Correct |
20 ms |
17132 KB |
Output is correct |
4 |
Correct |
20 ms |
17132 KB |
Output is correct |
5 |
Correct |
120 ms |
19852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
477 ms |
79612 KB |
Output is correct |
2 |
Correct |
525 ms |
82556 KB |
Output is correct |
3 |
Correct |
475 ms |
82556 KB |
Output is correct |
4 |
Correct |
503 ms |
82556 KB |
Output is correct |
5 |
Correct |
480 ms |
82556 KB |
Output is correct |
6 |
Correct |
478 ms |
82556 KB |
Output is correct |
7 |
Correct |
508 ms |
82556 KB |
Output is correct |
8 |
Correct |
522 ms |
82620 KB |
Output is correct |
9 |
Correct |
492 ms |
82620 KB |
Output is correct |
10 |
Correct |
600 ms |
82620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
268 ms |
82620 KB |
Output is correct |
2 |
Execution timed out |
1094 ms |
171884 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |