This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |