# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
597879 | 2022-07-17T03:30:06 Z | Hanksburger | 회문 (APIO14_palindrome) | C++17 | 30 ms | 35084 KB |
#include <bits/stdc++.h> using namespace std; int nxt[300005][26], len[300005], suff[300005], freq[300005], cur=1, cnt=2; string s; void add(int x) { while (s[x-len[cur]-1]!=s[x]) cur=suff[cur]; int y=s[x]-'a'; if (nxt[cur][y]) { cur=nxt[cur][y]; freq[cur]++; return; } nxt[cur][y]=++cnt; len[cnt]=len[cur]+2; freq[cnt]++; if (len[cnt]==1) { suff[cnt]=2; cur=cnt; return; } do cur=suff[cur]; while (s[x-len[cur]-1]!=s[x]); suff[cnt]=nxt[cur][y]; cur=cnt; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); len[1]=-1; suff[1]=suff[2]=1; cin >> s; for (int i=0; i<s.length(); i++) add(i); long long ans=0; for (int i=cnt; i>=3; i--) { ans=max(ans, 1LL*freq[i]*len[i]); freq[suff[i]]+=freq[i]; } cout << ans; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 276 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 256 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 0 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 0 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 0 ms | 340 KB | Output is correct |
29 | Correct | 0 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 340 KB | Output is correct |
31 | Correct | 0 ms | 340 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1492 KB | Output is correct |
2 | Correct | 1 ms | 1492 KB | Output is correct |
3 | Correct | 1 ms | 1492 KB | Output is correct |
4 | Correct | 1 ms | 1492 KB | Output is correct |
5 | Correct | 1 ms | 1492 KB | Output is correct |
6 | Correct | 1 ms | 1492 KB | Output is correct |
7 | Correct | 2 ms | 1492 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 2 ms | 1036 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 11860 KB | Output is correct |
2 | Correct | 10 ms | 11892 KB | Output is correct |
3 | Correct | 8 ms | 11860 KB | Output is correct |
4 | Correct | 9 ms | 11860 KB | Output is correct |
5 | Correct | 9 ms | 11860 KB | Output is correct |
6 | Correct | 6 ms | 8744 KB | Output is correct |
7 | Correct | 7 ms | 10068 KB | Output is correct |
8 | Correct | 2 ms | 596 KB | Output is correct |
9 | Correct | 3 ms | 3156 KB | Output is correct |
10 | Correct | 6 ms | 10068 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 34808 KB | Output is correct |
2 | Correct | 29 ms | 35084 KB | Output is correct |
3 | Correct | 30 ms | 35060 KB | Output is correct |
4 | Correct | 25 ms | 35004 KB | Output is correct |
5 | Correct | 23 ms | 35028 KB | Output is correct |
6 | Correct | 20 ms | 31288 KB | Output is correct |
7 | Correct | 23 ms | 29284 KB | Output is correct |
8 | Correct | 5 ms | 1248 KB | Output is correct |
9 | Correct | 5 ms | 1244 KB | Output is correct |
10 | Correct | 20 ms | 28876 KB | Output is correct |
11 | Correct | 23 ms | 34988 KB | Output is correct |
12 | Correct | 7 ms | 4316 KB | Output is correct |