結果

問題 No.273 回文分解
ユーザー hogeover30
提出日時 2016-07-25 01:32:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 69,424 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-25 13:39:19
合計ジャッジ時間 1,492 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

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

int main()
{
    string s; cin>>s;
    int n=s.size();
    int res=0;
    for(int i=0; i<n; ++i) {
        for(int m=1; m<n; ++m) {
            auto t=s.substr(i, m);
            if (isPalindrome(t) and res<t.size())
                res=t.size();
        }
    }
    cout<<res<<endl;
}
0