제출 #290394

#제출 시각아이디문제언어결과실행 시간메모리
290394ZwariowanyMarcin회문 (APIO14_palindrome)C++17
100 / 100
30 ms34944 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back #define ss(x) (int) x.size() #define cat(x) cerr << #x << " = " << x << endl using ll = long long; using namespace std; const int N = 3e5 + 100; const int A = 26; int cnt, len[N], link[N], last, nxt[N][A], q[N]; char s[N]; void add(int x) { int v = last, c = s[x] - 'a'; while (s[x] != s[x - len[v] - 1]) v = link[v]; if (!nxt[v][c]) { int ja = ++cnt, k = link[v]; len[ja] = len[v] + 2; while (s[x] != s[x - len[k] - 1]) k = link[k]; link[ja] = nxt[k][c], nxt[v][c] = ja; } q[nxt[v][c]]++; last = nxt[v][c]; } int main() { len[1] = -1; link[0] = link[1] = 1; cnt = 1; last = 0; scanf ("%s", s + 1); int n = strlen(s + 1); for (int i = 1; i <= n; ++i) add(i); ll out = 0; for (int i = cnt; 2 <= i; --i) { out = max(out, ll(len[i]) * q[i]); q[link[i]] += q[i]; } printf ("%lld\n", out); return 0; }

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

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