結果

問題 No.273 回文分解
ユーザー tetsuzuki1115
提出日時 2018-03-01 16:15:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 937 ms
コンパイル使用メモリ 85,692 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-25 13:53:48
合計ジャッジ時間 1,952 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    string S;
    cin >> S;
    int n = S.length();
    int ans = 0;
    for ( int i = 0; i < n; i++ ) {
    for ( int j = 1; i+j-1 < n; j++ ) {
        string s = S.substr( i, j );
        string t = s;
        reverse( t.begin(), t.end() );
        if ( s == t && j != n ) { ans =  max( ans, j ); }
    }
    }
    cout << ans << endl;
    return 0;
}
0