# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
71116 | 3zp | 구간 성분 (KOI15_interval) | C++14 | 1067 ms | 47392 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<bits/stdc++.h>
using namespace std;
int A = 987654323;
int B = 1e9 + 7;
int pol[26];
set<int> sa[1509];
main(){
pol[0] = 1;
for(int i = 1; i < 26; i ++)
pol[i] = (long long)pol[i - 1] * (long long)A % B;
int n, m;
string a, b;
cin >> a >> b;
n = a.size(), m = b.size();
for(int i = 0; i < n; i++){
long long H = 0;
for(int j = i; j < n; j++){
H += pol[a[j] - 'a'];
if(H > B) H -= B;
sa[j - i + 1].insert(H);
}
}
int ans = 0;
for(int i = 0; i < m; i++){
long long H = 0;
for(int j = i; j < m; j++){
H += pol[b[j] - 'a'];
if(H > B) H -= B;
if(sa[j - i + 1].find(H) != sa[j - i + 1].end()){
ans = max(ans, j - i + 1);
}
}
}
cout << ans << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |