結果
| 問題 |
No.273 回文分解
|
| コンテスト | |
| ユーザー |
hanorver
|
| 提出日時 | 2015-08-28 23:14:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 698 bytes |
| コンパイル時間 | 597 ms |
| コンパイル使用メモリ | 68,408 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 11:52:07 |
| 合計ジャッジ時間 | 1,622 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 WA * 3 |
ソースコード
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<algorithm>
int main() {
std::string str;
std::cin >> str;
std::vector<std::vector<int> > v(str.length(),std::vector<int>(str.length(),0));
int max = 0,second_max=0;
for (int i = 0; i < str.size(); i++) {
for (int j = 1; j <= str.size() - i; j++) {
std::string s = str.substr(i, j);
std::string r = s;
std::reverse(r.begin(), r.end());
if (s == r) {
v[i][j - 1] = s.length();
if (max < s.length()) {
second_max = max;
max = s.length();
}
}
}
}
if(max != str.length()){
std::cout << max << std::endl;
} else {
std::cout << second_max << std::endl;
}
return 0;
}
hanorver