# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
582935 | 600Mihnea | Palindromic Partitions (CEOI17_palindromic) | C++17 | 2 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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();
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;
}
/// interval[i] = [i, n - 1 - i]
for (int i = (n - 1) / 2; i >= 0; i--) {
if (i == n - 1 - i) {
continue;
}
for (int j = i; j <= n - 1 - j; j++) {
/// interval[i] = [i, n - 1 - i]
/// interval[j] = [j, n - 1 - j]
bool ok = 1;
for (int k = i; k <= j; k++) {
ok &= (a[k] == a[n - 1 - j + k - i]);
}
if (ok) {
mx[i] = max(mx[i], 2 + mx[j + 1]);
}
}
}
cout << mx[0] << "\n";
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |