Submission #915658

#TimeUsernameProblemLanguageResultExecution timeMemory
915658toonewbiePalindromic Partitions (CEOI17_palindromic)C++17
60 / 100
10031 ms4600 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 (!check_equal(l, r - len + 1, len)) { len++; } if (len == r - l + 1) { res++; break; } res += 2; l += len; r -= len; } 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...