# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
869247 | 2023-11-03T18:06:09 Z | LOLOLO | Palindromic Partitions (CEOI17_palindromic) | C++14 | 67 ms | 28440 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const int BASE = 37; long long haha[N]; long long hihi[N]; long long kkk(int L, int R) { return haha[R] - haha[L - 1] * hihi[R - L + 1]; } void solve() { string s; cin >> s; int n = s.size(); s = ' ' + s; for (int i = 1; i <= n; i++) haha[i] = haha[i - 1] * BASE + s[i] - 'a' + 1; int l = 1, r = n; int ahihi = 1, orz = n; long long hjhj, hehe; int ans = 0; while (l < r) { hjhj = kkk(ahihi, l); hehe = kkk(r, orz); if (hjhj == hehe) { ahihi = l + 1, orz = r - 1; ans += 2; hjhj = 0, hehe = 0; } l++; r--; } cout << ans + (l == r || hjhj != hehe) << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); hihi[0] = 1; for (int i = 1; i < N; i++) hihi[i] = hihi[i - 1] * BASE; int t; cin >> t; while (t--) solve(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8792 KB | Output is correct |
2 | Correct | 2 ms | 8796 KB | Output is correct |
3 | Correct | 2 ms | 8796 KB | Output is correct |
4 | Correct | 2 ms | 8796 KB | Output is correct |
5 | Correct | 2 ms | 8796 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8792 KB | Output is correct |
2 | Correct | 2 ms | 8796 KB | Output is correct |
3 | Correct | 2 ms | 8796 KB | Output is correct |
4 | Correct | 2 ms | 8796 KB | Output is correct |
5 | Correct | 2 ms | 8796 KB | Output is correct |
6 | Correct | 3 ms | 8796 KB | Output is correct |
7 | Correct | 2 ms | 8796 KB | Output is correct |
8 | Correct | 3 ms | 8796 KB | Output is correct |
9 | Correct | 3 ms | 8796 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8792 KB | Output is correct |
2 | Correct | 2 ms | 8796 KB | Output is correct |
3 | Correct | 2 ms | 8796 KB | Output is correct |
4 | Correct | 2 ms | 8796 KB | Output is correct |
5 | Correct | 2 ms | 8796 KB | Output is correct |
6 | Correct | 3 ms | 8796 KB | Output is correct |
7 | Correct | 2 ms | 8796 KB | Output is correct |
8 | Correct | 3 ms | 8796 KB | Output is correct |
9 | Correct | 3 ms | 8796 KB | Output is correct |
10 | Correct | 4 ms | 8796 KB | Output is correct |
11 | Correct | 3 ms | 8796 KB | Output is correct |
12 | Correct | 3 ms | 8796 KB | Output is correct |
13 | Correct | 3 ms | 8796 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8792 KB | Output is correct |
2 | Correct | 2 ms | 8796 KB | Output is correct |
3 | Correct | 2 ms | 8796 KB | Output is correct |
4 | Correct | 2 ms | 8796 KB | Output is correct |
5 | Correct | 2 ms | 8796 KB | Output is correct |
6 | Correct | 3 ms | 8796 KB | Output is correct |
7 | Correct | 2 ms | 8796 KB | Output is correct |
8 | Correct | 3 ms | 8796 KB | Output is correct |
9 | Correct | 3 ms | 8796 KB | Output is correct |
10 | Correct | 4 ms | 8796 KB | Output is correct |
11 | Correct | 3 ms | 8796 KB | Output is correct |
12 | Correct | 3 ms | 8796 KB | Output is correct |
13 | Correct | 3 ms | 8796 KB | Output is correct |
14 | Correct | 67 ms | 28440 KB | Output is correct |
15 | Correct | 37 ms | 23496 KB | Output is correct |
16 | Correct | 64 ms | 27580 KB | Output is correct |
17 | Correct | 38 ms | 19324 KB | Output is correct |