# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
468964 | 2021-08-30T09:52:20 Z | wdjpng | Palindromic Partitions (CEOI17_palindromic) | C++17 | 314 ms | 19192 KB |
#include <bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC optimize ("unroll-loops") #define int long long #define rep(i,n) for(int i = 0; i < n; i++) using namespace std; vector<int>powr(1e6+1); int mod = 1e9+7; int solve(string s) { int n = s.size(); int maxx = 1; int c = 0; int s1 = 0; int s2 = 0; rep(i,n) { if(i>=n-1-i) continue; s1=26*s1+s[i]-'a'; s2+=powr[c]*(s[n-i-1]-'a'); s1%=mod; s2%=mod; //cout<<s1<<" "<<s2<<"\n"; c++; if(s1==s2) { s1=0; s2=0; c=0; int cur = 2*(maxx/2) + 2; if(i+1!=n-1-i) cur++; maxx = cur; } } return maxx; } signed main() { int t; cin>>t; powr[0]=1; for(int i = 1; i<powr.size();i++) powr[i]=26*powr[i-1]%mod; while (t--) { string s; cin>>s; cout << solve(s) <<"\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 8012 KB | Output is correct |
2 | Correct | 13 ms | 8128 KB | Output is correct |
3 | Correct | 14 ms | 8132 KB | Output is correct |
4 | Correct | 14 ms | 8132 KB | Output is correct |
5 | Correct | 13 ms | 8012 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 8012 KB | Output is correct |
2 | Correct | 13 ms | 8128 KB | Output is correct |
3 | Correct | 14 ms | 8132 KB | Output is correct |
4 | Correct | 14 ms | 8132 KB | Output is correct |
5 | Correct | 13 ms | 8012 KB | Output is correct |
6 | Correct | 15 ms | 8132 KB | Output is correct |
7 | Correct | 14 ms | 8132 KB | Output is correct |
8 | Correct | 14 ms | 8128 KB | Output is correct |
9 | Correct | 13 ms | 8140 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 8012 KB | Output is correct |
2 | Correct | 13 ms | 8128 KB | Output is correct |
3 | Correct | 14 ms | 8132 KB | Output is correct |
4 | Correct | 14 ms | 8132 KB | Output is correct |
5 | Correct | 13 ms | 8012 KB | Output is correct |
6 | Correct | 15 ms | 8132 KB | Output is correct |
7 | Correct | 14 ms | 8132 KB | Output is correct |
8 | Correct | 14 ms | 8128 KB | Output is correct |
9 | Correct | 13 ms | 8140 KB | Output is correct |
10 | Correct | 17 ms | 8132 KB | Output is correct |
11 | Correct | 15 ms | 8140 KB | Output is correct |
12 | Correct | 17 ms | 8132 KB | Output is correct |
13 | Correct | 17 ms | 8140 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 8012 KB | Output is correct |
2 | Correct | 13 ms | 8128 KB | Output is correct |
3 | Correct | 14 ms | 8132 KB | Output is correct |
4 | Correct | 14 ms | 8132 KB | Output is correct |
5 | Correct | 13 ms | 8012 KB | Output is correct |
6 | Correct | 15 ms | 8132 KB | Output is correct |
7 | Correct | 14 ms | 8132 KB | Output is correct |
8 | Correct | 14 ms | 8128 KB | Output is correct |
9 | Correct | 13 ms | 8140 KB | Output is correct |
10 | Correct | 17 ms | 8132 KB | Output is correct |
11 | Correct | 15 ms | 8140 KB | Output is correct |
12 | Correct | 17 ms | 8132 KB | Output is correct |
13 | Correct | 17 ms | 8140 KB | Output is correct |
14 | Correct | 314 ms | 18856 KB | Output is correct |
15 | Correct | 174 ms | 15088 KB | Output is correct |
16 | Correct | 294 ms | 19192 KB | Output is correct |
17 | Correct | 170 ms | 14852 KB | Output is correct |