# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
99933 | 2019-03-08T19:40:33 Z | pavel | Palindromic Partitions (CEOI17_palindromic) | C++14 | 92 ms | 14940 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(ls<=rs){ 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 4224 KB | Output is correct |
2 | Correct | 11 ms | 4224 KB | Output is correct |
3 | Correct | 10 ms | 4224 KB | Output is correct |
4 | Correct | 10 ms | 4224 KB | Output is correct |
5 | Correct | 10 ms | 4224 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 4224 KB | Output is correct |
2 | Correct | 11 ms | 4224 KB | Output is correct |
3 | Correct | 10 ms | 4224 KB | Output is correct |
4 | Correct | 10 ms | 4224 KB | Output is correct |
5 | Correct | 10 ms | 4224 KB | Output is correct |
6 | Correct | 12 ms | 4224 KB | Output is correct |
7 | Correct | 11 ms | 4264 KB | Output is correct |
8 | Correct | 11 ms | 4224 KB | Output is correct |
9 | Correct | 12 ms | 4224 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 4224 KB | Output is correct |
2 | Correct | 11 ms | 4224 KB | Output is correct |
3 | Correct | 10 ms | 4224 KB | Output is correct |
4 | Correct | 10 ms | 4224 KB | Output is correct |
5 | Correct | 10 ms | 4224 KB | Output is correct |
6 | Correct | 12 ms | 4224 KB | Output is correct |
7 | Correct | 11 ms | 4264 KB | Output is correct |
8 | Correct | 11 ms | 4224 KB | Output is correct |
9 | Correct | 12 ms | 4224 KB | Output is correct |
10 | Correct | 11 ms | 4344 KB | Output is correct |
11 | Correct | 10 ms | 4224 KB | Output is correct |
12 | Correct | 11 ms | 4324 KB | Output is correct |
13 | Correct | 11 ms | 4352 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 4224 KB | Output is correct |
2 | Correct | 11 ms | 4224 KB | Output is correct |
3 | Correct | 10 ms | 4224 KB | Output is correct |
4 | Correct | 10 ms | 4224 KB | Output is correct |
5 | Correct | 10 ms | 4224 KB | Output is correct |
6 | Correct | 12 ms | 4224 KB | Output is correct |
7 | Correct | 11 ms | 4264 KB | Output is correct |
8 | Correct | 11 ms | 4224 KB | Output is correct |
9 | Correct | 12 ms | 4224 KB | Output is correct |
10 | Correct | 11 ms | 4344 KB | Output is correct |
11 | Correct | 10 ms | 4224 KB | Output is correct |
12 | Correct | 11 ms | 4324 KB | Output is correct |
13 | Correct | 11 ms | 4352 KB | Output is correct |
14 | Correct | 77 ms | 14940 KB | Output is correct |
15 | Correct | 63 ms | 10332 KB | Output is correct |
16 | Correct | 92 ms | 14576 KB | Output is correct |
17 | Correct | 41 ms | 9812 KB | Output is correct |