# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
122355 | 2019-06-28T05:27:12 Z | bekzhan29 | Palindromic Partitions (CEOI17_palindromic) | C++14 | 90 ms | 26788 KB |
#include <bits/stdc++.h> #include <iostream> #include <algorithm> #include <vector> #include <map> #include <unordered_map> #include <set> #include <queue> using namespace std; #define pb push_back #define mp make_pair #define INF 1e9 #define mod 1000000007 #define eps 1e-6 #define abs(x) ((x)>=0?(x):-(x)) #define y1 solai #define fi first #define se second typedef long long ll; void read(ll &x) { scanf("%lld",&x); } void read(ll &x, ll &y) { scanf("%lld%lld",&x,&y); } void read(ll &x, ll &y, ll &z) { scanf("%lld%lld%lld",&x,&y,&z); } void print(ll x) { printf("%lld ",x); } void println(ll x) { printf("%lld\n",x); } const ll N=1000100; ll t,n,ans,p[N],h[N],l,r,len; char s[N]; int main() { cin>>t; p[0]=1; for(ll i=1;i<N;i++) p[i]=p[i-1]*197; for(;t--;) { scanf("\n%s",s); n=strlen(s); for(ll i=1;i<=n;i++) h[i]=h[i-1]+s[i-1]*p[i]; l=1,r=n; ans=0; for(ll i=1;i<=n/2;i++) { len=i-l+1; if((h[i]-h[l-1])*p[r-i]==h[r]-h[r-len]) { ans+=2; l+=len; r-=len; } } if(l<=r) ans++; println(ans); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 8192 KB | Output is correct |
2 | Correct | 8 ms | 8192 KB | Output is correct |
3 | Correct | 9 ms | 8192 KB | Output is correct |
4 | Correct | 8 ms | 8192 KB | Output is correct |
5 | Correct | 8 ms | 8192 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 8192 KB | Output is correct |
2 | Correct | 8 ms | 8192 KB | Output is correct |
3 | Correct | 9 ms | 8192 KB | Output is correct |
4 | Correct | 8 ms | 8192 KB | Output is correct |
5 | Correct | 8 ms | 8192 KB | Output is correct |
6 | Correct | 9 ms | 8192 KB | Output is correct |
7 | Correct | 9 ms | 8192 KB | Output is correct |
8 | Correct | 9 ms | 8192 KB | Output is correct |
9 | Correct | 8 ms | 8192 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 8192 KB | Output is correct |
2 | Correct | 8 ms | 8192 KB | Output is correct |
3 | Correct | 9 ms | 8192 KB | Output is correct |
4 | Correct | 8 ms | 8192 KB | Output is correct |
5 | Correct | 8 ms | 8192 KB | Output is correct |
6 | Correct | 9 ms | 8192 KB | Output is correct |
7 | Correct | 9 ms | 8192 KB | Output is correct |
8 | Correct | 9 ms | 8192 KB | Output is correct |
9 | Correct | 8 ms | 8192 KB | Output is correct |
10 | Correct | 9 ms | 8320 KB | Output is correct |
11 | Correct | 10 ms | 8320 KB | Output is correct |
12 | Correct | 9 ms | 8320 KB | Output is correct |
13 | Correct | 9 ms | 8320 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 8192 KB | Output is correct |
2 | Correct | 8 ms | 8192 KB | Output is correct |
3 | Correct | 9 ms | 8192 KB | Output is correct |
4 | Correct | 8 ms | 8192 KB | Output is correct |
5 | Correct | 8 ms | 8192 KB | Output is correct |
6 | Correct | 9 ms | 8192 KB | Output is correct |
7 | Correct | 9 ms | 8192 KB | Output is correct |
8 | Correct | 9 ms | 8192 KB | Output is correct |
9 | Correct | 8 ms | 8192 KB | Output is correct |
10 | Correct | 9 ms | 8320 KB | Output is correct |
11 | Correct | 10 ms | 8320 KB | Output is correct |
12 | Correct | 9 ms | 8320 KB | Output is correct |
13 | Correct | 9 ms | 8320 KB | Output is correct |
14 | Correct | 89 ms | 26788 KB | Output is correct |
15 | Correct | 52 ms | 22108 KB | Output is correct |
16 | Correct | 90 ms | 26232 KB | Output is correct |
17 | Correct | 47 ms | 17916 KB | Output is correct |