#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
string A,B;
set<vector<int>> S;
int main()
{
cin>>A>>B;
for(int i=0;i<A.size();i++)
{
vector<int> p(26,0);
for(int j=i;j<A.size();j++)
{
p[A[j]-'a']++;
S.insert(p);
}
}
int ans=0;
for(int i=0;i<B.size();i++)
{
vector<int> p(26,0);
for(int j=i;j<B.size();j++)
{
p[B[j]-'a']++;
auto it=S.find(p);
if(it!=S.end()) ans=max(ans,j-i+1);
}
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1720 KB |
Output is correct |
2 |
Correct |
1 ms |
1852 KB |
Output is correct |
3 |
Correct |
0 ms |
1720 KB |
Output is correct |
4 |
Correct |
2 ms |
2380 KB |
Output is correct |
5 |
Correct |
3 ms |
2380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
83 ms |
14788 KB |
Output is correct |
2 |
Correct |
105 ms |
18220 KB |
Output is correct |
3 |
Correct |
57 ms |
2512 KB |
Output is correct |
4 |
Correct |
42 ms |
1720 KB |
Output is correct |
5 |
Correct |
114 ms |
20992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
483 ms |
80656 KB |
Output is correct |
2 |
Correct |
452 ms |
83428 KB |
Output is correct |
3 |
Correct |
467 ms |
82504 KB |
Output is correct |
4 |
Correct |
460 ms |
80656 KB |
Output is correct |
5 |
Correct |
426 ms |
83296 KB |
Output is correct |
6 |
Correct |
476 ms |
81052 KB |
Output is correct |
7 |
Correct |
463 ms |
83296 KB |
Output is correct |
8 |
Correct |
451 ms |
83428 KB |
Output is correct |
9 |
Correct |
458 ms |
83428 KB |
Output is correct |
10 |
Correct |
458 ms |
83032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
665 ms |
32872 KB |
Output is correct |
2 |
Memory limit exceeded |
489 ms |
131072 KB |
Memory limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |