Submission #1103894

# Submission time Handle Problem Language Result Execution time Memory
1103894 2024-10-22T06:37:46 Z ezzzay Palindromic Partitions (CEOI17_palindromic) C++14
100 / 100
173 ms 3296 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
vector<int>ans;
const int mod=1e9+5;
const int modd=31;
void fun(){
    string s;
    cin>>s;
    int n=s.size();
    int a=0,b=0;
    int x=-1;
    int p=0;
    int mlt=1;
    for(int i=0;i<n/2;i++){
        a=(a*modd+s[i])%mod;
        b=(s[n-i-1]*mlt+b)%mod;
        mlt=(mlt*modd)%mod;
       
        if(a==b){
            x=i;
            a=0,b=0;
            p+=2;
            mlt=1;
        }
    }
    if(n%2 or x<n/2-1)p++;
    ans.pb(p);
}
signed main(){
    int t;
    cin>>t;
    while(t--)fun();
    for(auto a:ans)cout<<a<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 3 ms 336 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 3 ms 336 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 173 ms 3296 KB Output is correct
15 Correct 88 ms 3192 KB Output is correct
16 Correct 148 ms 3224 KB Output is correct
17 Correct 86 ms 1844 KB Output is correct