結果
問題 | No.273 回文分解 |
ユーザー |
![]() |
提出日時 | 2015-10-20 01:09:00 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 608 bytes |
コンパイル時間 | 470 ms |
コンパイル使用メモリ | 59,704 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-25 13:31:30 |
合計ジャッジ時間 | 1,511 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <iostream>#include <sstream>#include <algorithm>using namespace std;int check(string s) {int r = 1;int len = s.length();for (int i = 1; i < len; ++i) {for (int j = 1; j <= i && i + j < len; ++j) {if (s[i - j] != s[i + j]) {break;}r = max(r, j * 2 + 1);}for (int j = 1; j <= i && i + j - 1 < len; ++j) {if (s[i - j] != s[i + j - 1]) {break;}r = max(r, j * 2);}}return r;}int main(int argc, char *argv[]) {string s;cin >> s;int ans = max(check(s.substr(0, s.length() - 1)), check(s.substr(1)));cout << ans << endl;return 0;}