Submission #261000

#TimeUsernameProblemLanguageResultExecution timeMemory
261000atoizPalindromes (APIO14_palindrome)C++14
0 / 100
28 ms35168 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cstdio> #include <cmath> #include <cstring> using namespace std; const int MAXN = 300007; int link[MAXN], nxt[MAXN][26], len[MAXN], val[MAXN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); string S; cin >> S; len[1] = -1, len[2] = 0; link[2] = 1; int u = 2, cnt = 2; int N = ((int) S.size()); S = "-" + S; for (int i = 1; i <= N; ++i) { int c = (int) (S[i] - 'a'); while (S[i] != S[i - len[u] - 1]) u = link[u]; if (!nxt[u][c]) { nxt[u][c] = ++cnt; // cout << u << " -> " << nxt[u][c] << ": " << char(c + 'a') << endl; len[nxt[u][c]] = len[u] + 2; int v; for (v = link[u]; v && !nxt[v][c]; v = link[v]); if (v == 0) link[nxt[u][c]] = 2; else link[nxt[u][c]] = nxt[v][c]; } u = nxt[u][c]; ++val[u]; } int64_t ans = 0; for (int u = cnt; u > 2; --u) { if (link[u]) val[link[u]] += val[u]; ans = max(ans, (int64_t) val[u] * len[u]); } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...