제출 #401304

#제출 시각아이디문제언어결과실행 시간메모리
401304aymanrsPalindromic Partitions (CEOI17_palindromic)C++14
0 / 100
1 ms204 KiB
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
void solve(){
    string s;
    cin >> s;
    long long a = 0, b = 0, p = 1;
    int n = s.size(), i = 0, j = n-1, ans = 0;
    while(i < j){
        a = (a * 26 + (s[i] - 'a')) % MOD;
        b = ((s[j] - 'a') * p + b) % MOD;
        p = p*26%MOD;
        i++;
        j--;
        if(a == b){
            a = b = 0;
            ans += 2;
        }
    }
    if(a != b) ans++;
    cout << ans << '\n';
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--) solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...