結果
| 問題 |
No.273 回文分解
|
| コンテスト | |
| ユーザー |
stack9996
|
| 提出日時 | 2015-08-29 12:43:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 740 bytes |
| コンパイル時間 | 601 ms |
| コンパイル使用メモリ | 73,308 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 13:27:00 |
| 合計ジャッジ時間 | 1,650 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include <iostream>
#include <cstdio>
#include <numeric>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <cmath>
#include <queue>
#define rep(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
struct edge{ int to, time, cost; };
std::string str;
int dp[51];
int main(){
std::cin >> str;
dp[0] = 0;
rep(i, str.size()){
for (int j = i + 1; j <= str.size(); ++j){
if (j - i == str.size())continue;
std::string s = str.substr(i, j - i);
if (s == std::string(s.rbegin(), s.rend()))dp[j] = std::max({ dp[j], dp[i], j - i });
}
}
std::cout << dp[str.size()] << std::endl;
return 0;
}
stack9996