# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
99931 | 2019-03-08T19:33:07 Z | pavel | Palindromic Partitions (CEOI17_palindromic) | C++14 | 28 ms | 8184 KB |
#include <cstdio> #include <cstring> using namespace std; typedef long long ll; const int MAXN = 1000006; const int MOD = 1000000007; const int BASE = 34; int n; char str[MAXN]; int p[MAXN]; int ADD(ll a, ll b){ return (a+b)%MOD; } int MUL(ll a, ll b){ return a*b%MOD; } int main(){ p[0]=1; for(int i=1;i<MAXN;++i) p[i]=MUL(BASE, p[i-1]); int tcc; scanf("%d", &tcc); for(int tc=0;tc<tcc;++tc){ scanf("%s", str); n=strlen(str); int ls=0,rs=n-1, le=1, re=n; int lh=str[0]-'a'+1, rh=str[n-1]-'a'+1; int sol=0; while(true){ while(lh!=rh){ lh=ADD(MUL(lh, BASE), str[le]-'a'+1); ++le; --rs; rh=ADD(MUL(str[rs]-'a'+1, p[re-rs-1]), rh); } if(ls==rs && le==re){ sol++; break; }else{ sol+=2; } ls=le;le=ls+1;lh=str[ls]-'a'+1; re=rs;rs=re-1;rh=str[rs]-'a'+1; } printf("%d\n", sol); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 28 ms | 8184 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 28 ms | 8184 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 28 ms | 8184 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 28 ms | 8184 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |