# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
71116 | 3zp | 구간 성분 (KOI15_interval) | C++14 | 1067 ms | 47392 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |