結果

問題 No.273 回文分解
ユーザー izryt(趣味)
提出日時 2016-01-17 08:14:32
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 498 bytes
コンパイル時間 1,294 ms
コンパイル使用メモリ 160,912 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-25 13:33:48
合計ジャッジ時間 2,293 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

string S;

bool is_palindrome(string a)
{
    int n = a.size();
    for (int i = 0; i < n / 2; ++i) if (a[i] != a[n - i - 1]) return false;
    return true;
}

int main()
{
    cin >> S;

    for (int i = S.size() - 1; i >= 1; --i) {
        for (int j = 0; j + i <= S.size(); ++j) {
            if (is_palindrome(S.substr(j, i))) {
                cout << i << endl;
                return 0;
            }
        }
    }

    cout << 0 << endl;
}
0