Submission #468968

#TimeUsernameProblemLanguageResultExecution timeMemory
468968paga2004Palindromic Partitions (CEOI17_palindromic)C++17
0 / 100
0 ms204 KiB
#include <bits/stdc++.h> #ifdef LOCAL #define dbg(x) cerr << "dgb: " << x << "\n"; #else #define dbg(x) #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,tune=native") #endif #define int int_fast64_t using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t--) { string s; cin >> s; dbg(s); int res = 0; int l = 0, r = (int)s.size() - 1; while (l <= r) { dbg("l " << l << " r " << r); int len = 1; while (s[l] != s[r]) { r--; len++; } if (r == l) { res++; goto end; } dbg("len " << len); dbg(s.substr(l, len)); dbg(s.substr(r, len)); if (s.substr(l, len) != s.substr(r, len)) { res++; goto end; } res += 2; l += len; r--; dbg("l " << l << " r " << r); } end: cout << res << "\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...