#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef vector<int> vi;
set<vi> gg;
int main()
{
cin.tie(NULL); ios::sync_with_stdio(false);
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)) { cout<<i; return 0;}
if(++e<l2) alpha[s2[e]-'a']++,alpha[s2[s++]-'a']--;
}
}
cout<<0;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
3 ms |
560 KB |
Output is correct |
4 |
Correct |
7 ms |
1276 KB |
Output is correct |
5 |
Correct |
5 ms |
1312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
82 ms |
13756 KB |
Output is correct |
2 |
Correct |
90 ms |
17116 KB |
Output is correct |
3 |
Correct |
20 ms |
17116 KB |
Output is correct |
4 |
Correct |
14 ms |
17116 KB |
Output is correct |
5 |
Correct |
119 ms |
19944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
543 ms |
79808 KB |
Output is correct |
2 |
Correct |
582 ms |
82520 KB |
Output is correct |
3 |
Correct |
495 ms |
82520 KB |
Output is correct |
4 |
Correct |
575 ms |
82520 KB |
Output is correct |
5 |
Correct |
514 ms |
82616 KB |
Output is correct |
6 |
Correct |
478 ms |
82616 KB |
Output is correct |
7 |
Correct |
509 ms |
82616 KB |
Output is correct |
8 |
Correct |
506 ms |
82684 KB |
Output is correct |
9 |
Correct |
547 ms |
82684 KB |
Output is correct |
10 |
Correct |
527 ms |
82684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
257 ms |
82684 KB |
Output is correct |
2 |
Execution timed out |
1092 ms |
172076 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |