結果

問題 No.273 回文分解
ユーザー hiro71687k
提出日時 2023-08-06 06:24:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 3,664 ms
コンパイル使用メモリ 252,152 KB
最終ジャッジ日時 2025-02-15 23:41:42
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=1000000007;
ll inf=10099999999999990;
int main(){
    string s;
    cin >> s;
    ll ans=0;
    for (ll i = 0; i < s.size(); i++)
    {
        for (ll j = 0; j < s.size(); j++)
        {
            if (i==0&&j==s.size()-1)
            {
                continue;
            }
            
            string t;
            for (ll k = i; k <= j; k++)
            {
                t.push_back(s[k]);
            }
            string u=t;
            reverse(u.begin(),u.end());
            if (t==u)
            {
                ans=max(ans,(ll)t.size());
            }
        }
    }
    cout << ans << endl;
}
0