# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
994970 | 2024-06-08T08:57:52 Z | doducanh | Palindromic Partitions (CEOI17_palindromic) | C++14 | 54 ms | 12972 KB |
#include <bits/stdc++.h> using namespace std; #define int long long const int mod=1e9+7; const int maxn=1e6+7; //int p[maxn]; //int h[maxn]; string s; int t; //int get(int l,int r) //{ // return (h[r]-(h[l-1]*p[r-l+1]%mod)+mod)%mod; //} void sol() { cin>>s; int n=s.size(); s=" "+s; int found=0; int start=1; int ans=0; while(found!=-1){ int left=0; int right=0; found=-1; for(int i=start,p=1;i<=n/2;i++,p=(p*32)%mod){ left=((left*32)%mod+(s[i]-'a'+1))%mod; right=(right+(p*(s[n-i+1]-'a'+1))%mod)%mod; // cout<<left<<" "<<right<<" "<<s[i]<<"\n"; if(left==right){ found=i; start=found+1; break; } } if(found!=-1){ ans+=2; } } if((start-1)*2==n)cout<<ans<<"\n"; else cout<<ans+1<<"\n"; } main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>t; while(t--){ sol(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 48 ms | 12116 KB | Output is correct |
15 | Correct | 30 ms | 7328 KB | Output is correct |
16 | Correct | 54 ms | 12972 KB | Output is correct |
17 | Correct | 23 ms | 6632 KB | Output is correct |