Submission #952234

#TimeUsernameProblemLanguageResultExecution timeMemory
952234sofija6Palindromic Partitions (CEOI17_palindromic)C++14
0 / 100
0 ms348 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++; 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...