제출 #49511

#제출 시각아이디문제언어결과실행 시간메모리
49511hamzqq9회문 (APIO14_palindrome)C++14
0 / 100
47 ms36964 KiB
#include<bits/stdc++.h> #define lf double #define ll long long #define cc pair<char,char> #define ull unsigned ll #define ii pair<int,int> #define li pair<ll,int> #define iii pair<int,ii> #define iiii pair<ii,ii> #define iiii2 pair<int,iii> #define lii pair<ll,ii> #define lolo pair<ll,ll> #define heap priority_queue #define mp make_pair #define st first #define nd second #define pb push_back #define pf push_front #define ppb pop_back #define ppf pop_front #define all(x) x.begin(),x.end() #define len(x) strlen(x) #define sz(x) (int) x.size() #define orta ((bas+son)/2) #define min3(x,y,z) min(min(x,y),z) #define max3(x,y,z) max(max(x,y),z) #define umin(x,y) x=min(x,y) #define umax(x,y) x=max(x,y) #define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" " #define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar() #define MOD 1000000000 #define inf 1000000005 #define N 300005 #define LOG 20 #define magic 100 #define KOK 250 #define EPS 0.0025 #define pw(x) (1<<(x)) #define PI 3.1415926535 using namespace std; int tot=2,n,now; int nxt[N][26],link[N],lazy[N],len[N]; char s[N]; ll ans; stack<int> stc; 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; stc.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() { #if 0 freopen("input.txt","r",stdin); #endif 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(!stc.empty()) { int x=stc.top(); stc.pop(); ans=max(ans,1ll*len[x]*lazy[x]); lazy[link[x]]++; } printf("%lld",ans); }

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

palindrome.cpp: In function 'int main()':
palindrome.cpp:97:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  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...