답안 #582940

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
582940 2022-06-24T15:39:43 Z 600Mihnea Palindromic Partitions (CEOI17_palindromic) C++17
35 / 100
10000 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

const int N = (int) 1e6 + 7;
int n;
int a[N];
int mx[N];

signed main() {
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  ///freopen ("input.txt", "r", stdin);

  int Tests;
  cin >> Tests;
  for (int tc = 1; tc <= Tests; tc++) {
      {
      string str;
      cin >> str;
      n = (int) str.size();
      if (n == 1) {
        cout << "1\n";
        continue;
      }
      for (int i = 0; i < n; i++) {
        char ch = str[i];
        assert('a' <= ch && ch <= 'z');
        a[i] = ch - 'a';
        assert(0 <= a[i] && a[i] < 26);
      }
      for (int i = 0; i <= n + 1; i++) {
        mx[i] = 0;
      }
      for (int i = 0; i <= (n - 1) / 2; i++) {
        mx[i] = 1;
      }
      for (int i = (n - 2) / 2; i >= 0; i--) {
        for (int j = i; j <= n - 1 - j; j++) {
          bool ok = 1;
          for (int k = 0; k <= j - i; k++) {
            ok &= (a[i + k] == a[n - 1 - j + k]);
          }
          if (ok) {
            mx[i] = max(mx[i], 2 + mx[j + 1]);
          }
        }
      }
      cout << mx[0] << "\n";
    }
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 6 ms 336 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 5 ms 340 KB Output is correct
9 Correct 4 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 6 ms 336 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 5 ms 340 KB Output is correct
9 Correct 4 ms 340 KB Output is correct
10 Execution timed out 10068 ms 340 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 6 ms 336 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 5 ms 340 KB Output is correct
9 Correct 4 ms 340 KB Output is correct
10 Execution timed out 10068 ms 340 KB Time limit exceeded
11 Halted 0 ms 0 KB -