# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83288 | 2018-11-06T17:26:18 Z | farukkastamonuda | Palindromes (APIO14_palindrome) | C++14 | 62 ms | 41312 KB |
#include <bits/stdc++.h> #define li 300005 #define inf 1000000009 #define md 1000000007 #define lo long long #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; int n,link[li],len[li],now,lazy[li]; char s[li]; int tot=2,nxt[li][26]; stack<int> st; lo int ans; void add(int ind){ while(s[ind-len[now]-1]!=s[ind]) now=link[now]; if(nxt[now][s[ind]-'a']){ now=nxt[now][s[ind]-'a']; lazy[now]++; return ; } int nw=++tot; nxt[now][s[ind]-'a']=nw; len[nw]=len[now]+2; st.push(nw); lazy[nw]++; if(len[nw]==1){ link[nw]=2; now=nw; return ; } now=link[now]; while(s[ind-len[now]-1]!=s[ind]) now=link[now]; link[nw]=nxt[now][s[ind]-'a']; now=nw; } int main(){ scanf("%s",s+1); n=strlen(s+1); link[1]=1;link[2]=1; len[1]=-1;len[2]=0; now=1; for(int i=1;i<=n;i++) add(i); while(!st.empty()){ int x=st.top(); st.pop(); ans=max(ans,1ll*len[x]*lazy[x]); lazy[link[x]]+=lazy[x]; } printf("%lld\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 576 KB | Output is correct |
3 | Correct | 2 ms | 576 KB | Output is correct |
4 | Correct | 2 ms | 616 KB | Output is correct |
5 | Correct | 2 ms | 728 KB | Output is correct |
6 | Correct | 2 ms | 840 KB | Output is correct |
7 | Correct | 2 ms | 840 KB | Output is correct |
8 | Correct | 2 ms | 840 KB | Output is correct |
9 | Correct | 2 ms | 840 KB | Output is correct |
10 | Correct | 2 ms | 840 KB | Output is correct |
11 | Correct | 2 ms | 860 KB | Output is correct |
12 | Correct | 2 ms | 864 KB | Output is correct |
13 | Correct | 2 ms | 868 KB | Output is correct |
14 | Correct | 2 ms | 872 KB | Output is correct |
15 | Correct | 2 ms | 876 KB | Output is correct |
16 | Correct | 2 ms | 884 KB | Output is correct |
17 | Correct | 2 ms | 884 KB | Output is correct |
18 | Correct | 2 ms | 976 KB | Output is correct |
19 | Correct | 2 ms | 976 KB | Output is correct |
20 | Correct | 2 ms | 976 KB | Output is correct |
21 | Correct | 2 ms | 1032 KB | Output is correct |
22 | Correct | 2 ms | 1032 KB | Output is correct |
23 | Correct | 2 ms | 1032 KB | Output is correct |
24 | Correct | 3 ms | 1032 KB | Output is correct |
25 | Correct | 2 ms | 1032 KB | Output is correct |
26 | Correct | 2 ms | 1032 KB | Output is correct |
27 | Correct | 2 ms | 1032 KB | Output is correct |
28 | Correct | 2 ms | 1032 KB | Output is correct |
29 | Correct | 2 ms | 1032 KB | Output is correct |
30 | Correct | 2 ms | 1032 KB | Output is correct |
31 | Correct | 2 ms | 1032 KB | Output is correct |
32 | Correct | 2 ms | 1032 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1248 KB | Output is correct |
2 | Correct | 2 ms | 1248 KB | Output is correct |
3 | Correct | 2 ms | 1252 KB | Output is correct |
4 | Correct | 2 ms | 1252 KB | Output is correct |
5 | Correct | 2 ms | 1260 KB | Output is correct |
6 | Correct | 2 ms | 1260 KB | Output is correct |
7 | Correct | 2 ms | 1260 KB | Output is correct |
8 | Correct | 2 ms | 1276 KB | Output is correct |
9 | Correct | 2 ms | 1276 KB | Output is correct |
10 | Correct | 2 ms | 1276 KB | Output is correct |
11 | Correct | 2 ms | 1276 KB | Output is correct |
12 | Correct | 2 ms | 1276 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2444 KB | Output is correct |
2 | Correct | 3 ms | 2452 KB | Output is correct |
3 | Correct | 3 ms | 2480 KB | Output is correct |
4 | Correct | 3 ms | 2492 KB | Output is correct |
5 | Correct | 3 ms | 2564 KB | Output is correct |
6 | Correct | 4 ms | 2564 KB | Output is correct |
7 | Correct | 4 ms | 2564 KB | Output is correct |
8 | Correct | 2 ms | 2564 KB | Output is correct |
9 | Correct | 2 ms | 2564 KB | Output is correct |
10 | Correct | 3 ms | 2564 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 13364 KB | Output is correct |
2 | Correct | 17 ms | 13592 KB | Output is correct |
3 | Correct | 17 ms | 13592 KB | Output is correct |
4 | Correct | 17 ms | 13712 KB | Output is correct |
5 | Correct | 22 ms | 13812 KB | Output is correct |
6 | Correct | 15 ms | 13812 KB | Output is correct |
7 | Correct | 15 ms | 13812 KB | Output is correct |
8 | Correct | 4 ms | 13812 KB | Output is correct |
9 | Correct | 6 ms | 13812 KB | Output is correct |
10 | Correct | 15 ms | 13812 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 46 ms | 38348 KB | Output is correct |
2 | Correct | 46 ms | 38644 KB | Output is correct |
3 | Correct | 46 ms | 38940 KB | Output is correct |
4 | Correct | 48 ms | 39236 KB | Output is correct |
5 | Correct | 62 ms | 39476 KB | Output is correct |
6 | Correct | 44 ms | 39476 KB | Output is correct |
7 | Correct | 43 ms | 39476 KB | Output is correct |
8 | Correct | 8 ms | 39476 KB | Output is correct |
9 | Correct | 7 ms | 39476 KB | Output is correct |
10 | Correct | 42 ms | 39476 KB | Output is correct |
11 | Correct | 45 ms | 41312 KB | Output is correct |
12 | Correct | 11 ms | 41312 KB | Output is correct |