Submission #952236

# Submission time Handle Problem Language Result Execution time Memory
952236 2024-03-23T10:35:20 Z sofija6 Palindromic Partitions (CEOI17_palindromic) C++14
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll t,n,p=31;
    string s;
    cin >> t;
    while (t--)
    {
        cin >> s;
        n=s.size();
        s=' '+s;
        ll ans=0,l=1,r=n,curl=0,curr=0,d=1;
        while (true)
        {
            if (l>=r)
            {
                ans+=(l==r);
                break;
            }
            curl=(curl+(s[l]-'a'+1)*d)%MOD;
            d=(d*p)%MOD;
            curr=(curr*p+s[r]-'a'+1)%MOD;
            if (curl==curr)
            {
                ans+=2;
                d=1;
                curl=curr=0;
            }
            l++;
            r--;
        }
        cout << ans << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -