Submission #856327

# Submission time Handle Problem Language Result Execution time Memory
856327 2023-10-03T06:21:16 Z Cyanmond Palindromic Partitions (CEOI17_palindromic) C++17
60 / 100
10000 ms 10292 KB
#include <bits/stdc++.h>

using namespace std;

#define rep(i, l, r) for (int i = (l); i < (r); ++i)
#define per(i, l, r) for (int i = (r - 1); i >= l; --i)
#define ALL(x) (x).begin(), (x).end()

using i64 = long long;

void main_() {
    string S;
    cin >> S;
    const int N = (int)S.size();

    string A = S.substr(0, N / 2), B = S.substr(N - N / 2, N / 2);
    reverse(ALL(B));
    const int M = (int)A.size();
    vector<int> dp(M + 1, -(2 * N));
    dp[0] = 0;
    rep(i, 0, M) {
        string x, y;
        rep(j, i, M) {
            x += A[j];
            y = B[j] + y;
            if (x == y) {
                dp[j + 1] = max(dp[j + 1], dp[i] + 2);
                break;
            }
        }
    }
    for (auto &e : dp) ++e;
    if (N % 2 == 0) --dp[M];

    cout << *max_element(ALL(dp)) << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    while (T--) main_();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 17 ms 348 KB Output is correct
11 Correct 1738 ms 596 KB Output is correct
12 Correct 97 ms 604 KB Output is correct
13 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 17 ms 348 KB Output is correct
11 Correct 1738 ms 596 KB Output is correct
12 Correct 97 ms 604 KB Output is correct
13 Correct 4 ms 348 KB Output is correct
14 Execution timed out 10096 ms 10292 KB Time limit exceeded
15 Halted 0 ms 0 KB -