Submission #952236

#TimeUsernameProblemLanguageResultExecution timeMemory
952236sofija6Palindromic Partitions (CEOI17_palindromic)C++14
0 / 100
0 ms344 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...