# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
977806 | 2024-05-08T11:17:29 Z | duckindog | Palindromic Partitions (CEOI17_palindromic) | C++17 | 3 ms | 8796 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1'000'000 + 10; int t; using ull = unsigned long long; ull h[N], pw[N]; ull get(int l, int r) { return h[r] - h[l - 1] * pw[r - l + 1]; } int32_t main() { cin.tie(0)->sync_with_stdio(0); pw[0] = 1; for (int i = 1; i <= 1'000'000; ++i) pw[i] = pw[i - 1] * 19937; cin >> t; while (t--) { string s; cin >> s; for (int i = 1; i <= s.size(); ++i) h[i] = h[i - 1] * 19937 + s[i - 1]; int l = 1, r = s.size(); int answer = 0; int len = 0; while (true) { if (l + len >= r - len) { answer += 1; break; } if (get(l, l + len) != get(r - len, r)) len += 1; else { answer += 2; l = l + len + 1; r = r - len - 1; len = 0; } } cout << answer << "\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 8796 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 8796 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 8796 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 8796 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |