제출 #102232

#제출 시각아이디문제언어결과실행 시간메모리
102232KastandaPalindromes (APIO14_palindrome)C++11
100 / 100
56 ms34976 KiB
#include<bits/stdc++.h> using namespace std; const int MXN = 300005, SGM = 26; int n, ts, C[MXN][SGM], len[MXN], link[MXN], cnt[MXN]; char S[MXN]; inline int GetLink(int nw, int i) { while (S[i] != S[i - len[nw] - 1]) nw = link[nw]; return (nw); } inline int Add(int nw, int i) { int ch = S[i] - 'a'; nw = GetLink(nw, i); if (!C[nw][ch]) { ++ ts; len[ts] = len[nw] + 2; link[ts] = C[GetLink(link[nw], i)][ch]; C[nw][ch] = ts; } return (C[nw][ch]); } int main() { scanf("%s", S); n = strlen(S); len[1] = -1; ts = 1; link[0] = link[1] = 1; int nw = 1; for (int i = 1; i <= n; i++) nw = Add(nw, i - 1), cnt[nw] ++; long long Mx = 0; for (int i = ts; i >= 0; i--) cnt[link[i]] += cnt[i], Mx = max(Mx, 1LL * cnt[i] * len[i]); return !printf("%lld\n", Mx); }

컴파일 시 표준 에러 (stderr) 메시지

palindrome.cpp: In function 'int main()':
palindrome.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", S);
     ~~~~~^~~~~~~~~
#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...