Submission #35493

#TimeUsernameProblemLanguageResultExecution timeMemory
35493imaxbluePalindromic Partitions (CEOI17_palindromic)C++14
100 / 100
403 ms12792 KiB
#include <iostream> using namespace std; const int seed=1337, mod=1000000007; string s; int t, x, p, c, y; int fwh[1000005], bwh[1000005]; int main() { cin >> t; for (int l=0; l<t; ++l){ cin >> s; x=0; y=0; p=1; c=1; for (int l=0; l<s.size()/2; ++l){ x=(1LL*x*seed)%mod+s[l]-'a'+1; y=(y+(1LL*p*(s[s.size()-l-1]-'a'+1)))%mod; p=(1LL*p*seed)%mod; if (x==y){ //cout << l << ' '; c+=2; x=0; y=0; p=1; if ((l+1)*2==s.size()) c--; } } //for (int l=0; l<s.size(); ++l) cout << fwh[l] << ' ' ; cout << endl; //for (int l=0; l<s.size(); ++l) cout << bwh[l] << ' ' ; cout << endl; cout << c << endl; } return 0; }

Compilation message (stderr)

palindromic.cpp: In function 'int main()':
palindromic.cpp:14:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int l=0; l<s.size()/2; ++l){
                        ^
palindromic.cpp:22:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if ((l+1)*2==s.size()) c--;
                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...