# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
29787 | 2017-07-20T16:12:45 Z | TAMREF | Palinilap (COI16_palinilap) | C++11 | 1000 ms | 2072 KB |
#include <bits/stdc++.h> using namespace std; const int mx=5005; char a[mx],S[mx<<1]; int dp[mx<<1], Z, r,p,np; void input(){ scanf("%s",a); int N=strlen(a); int i=0; for(int k=0;k<N;k++){ S[++i]=a[k]; S[++i]='*'; } Z=2*N-1; } int Manacher(int t, char c){ r=p=np=0; //p=np char x=S[t]; S[t]=c; for(int i=1;i<=Z;i++){ dp[i]=(i>r)?0:min(dp[2*p-i],r-i); for(;i+dp[i]+1<=Z && S[i+dp[i]+1]==S[i-dp[i]-1];++dp[i]); if(i+dp[i]>r) p=i,r=i+dp[i]; if(dp[i]==i-1||dp[i]+i==Z) np+=(S[i]=='*'?(dp[i]+1)>>1:(dp[i]+2)>>1); else np+=(S[i]=='*'?(dp[i]>>1):(dp[i]+1)>>1); } S[t]=x; return np; } int main(){ input(); int X=0; for(int i=1;i<=Z;i+=2){ for(char x='a';x<='z';x++){ X=max(X,Manacher(i,x)); } } printf("%d\n",X); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2072 KB | Output is correct |
2 | Correct | 3 ms | 2072 KB | Output is correct |
3 | Correct | 6 ms | 2072 KB | Output is correct |
4 | Correct | 3 ms | 2072 KB | Output is correct |
5 | Correct | 3 ms | 2072 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 2072 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 2072 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |