Submission #915652

#TimeUsernameProblemLanguageResultExecution timeMemory
915652toonewbiePalindromic Partitions (CEOI17_palindromic)C++17
0 / 100
1 ms348 KiB
#pragma GCC optimize("O3") #include <iostream> using namespace std; int n; string s; bool check_equal(int a, int b, int l) { for (int i = 0; i < l; i++) { if (s[a + i] != s[b + i]) { return false; } } return true; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int T; cin >> T; while(T--) { cin >> s; n = s.size(); int res = 0; int l = 0, r = n - 1; while(l < r) { int len = 1; while (l + len <= r && !check_equal(l, r - len + 1, len)) { len++; } res += 2; l += len; r -= len; } if (l == r) { res++; } else if (l > r) { res--; } cout << res << "\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...