Submission #1103888

#TimeUsernameProblemLanguageResultExecution timeMemory
1103888ezzzayPalindromic Partitions (CEOI17_palindromic)C++14
100 / 100
170 ms12132 KiB
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T--) { string S; cin >> S; int N = S.size() / 2; long long cur1 = 0, cur2 = 0; long long a = 31, b = 1e9+7, mult = 1; int last = -1; int nb = 0; for (int i = 0; i < N; i++) { cur1 = (cur1 * a + S[i]) % b; cur2 = (cur2 + mult * S[S.size() - i - 1]) % b; mult = (mult * a) % b; if (cur1 == cur2) { last = i; cur1 = 0, cur2 = 0, mult = 1; nb += 2; } } if (S.size() % 2 || last < N - 1) nb++; cout << nb << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...