Submission #936278

# Submission time Handle Problem Language Result Execution time Memory
936278 2024-03-01T14:03:49 Z Aiperiii Palindromic Partitions (CEOI17_palindromic) C++14
0 / 100
5 ms 8028 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int N=1e6+5,tt=31,mod=1e9+7;
int pw[N];
signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    pw[0]=1;
    for(int i=1;i<N;i++)pw[i]=pw[i-1]*tt%mod;
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int l=0,r=s.size()-1;
        int sz=0,x=0,y=0,res=0;
        while(l<r){
            sz++;
            x+=pw[sz]*(s[l]-'a'+1)%mod;
            y*=tt%mod;
            y+=(s[r]-'a'+1)*tt%mod;
            if(x==y){
                res+=2;
                x=0;y=0;sz=0;
            }
            l++;r--;
        }
        if(l==r)sz++;
        if(sz)res++;
        cout<<res<<"\n";
    }
}
/*
4
bonobo
deleted
racecar
racecars
 */
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 8028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 8028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 8028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 8028 KB Output isn't correct
2 Halted 0 ms 0 KB -