結果
| 問題 |
No.273 回文分解
|
| コンテスト | |
| ユーザー |
n_knuu
|
| 提出日時 | 2015-09-19 12:48:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 991 bytes |
| コンパイル時間 | 1,385 ms |
| コンパイル使用メモリ | 159,076 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-25 13:29:48 |
| 合計ジャッジ時間 | 2,282 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
bool par[64][64];
int dp[64][64];
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
string S;
cin >> S;
int N = S.size();
REP(i, N) REP(j, N) par[i][j] = false;
REP(i, N) {
for (int l = i, r = i; l >= 0 && r < N && S[l] == S[r]; l--, r++) {
par[l][r] = true;
}
for (int l = i, r = i+1; l >= 0 && r < N && S[l] == S[r]; l--, r++) {
par[l][r] = true;
}
}
par[0][N-1] = false;
REP(i, N) {
FOR(j, i, N) {
if (par[i][j]) {
dp[j+1][j+1] = max(dp[j+1][j+1], j - i + 1);
}
}
dp[i+1][i+1] = max(dp[i+1][i+1], dp[i][i]);
}
cout << dp[N][N] << endl;
return 0;
}
n_knuu