結果
| 問題 | No.588 空白と回文 | 
| コンテスト | |
| ユーザー |  tetsuzuki1115 | 
| 提出日時 | 2018-03-31 15:18:47 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 5 ms / 2,000 ms | 
| コード長 | 782 bytes | 
| コンパイル時間 | 859 ms | 
| コンパイル使用メモリ | 83,948 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-26 01:35:23 | 
| 合計ジャッジ時間 | 1,751 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 25 | 
ソースコード
#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 ans = 0;
    for ( int i = 0; i < S.length(); i++ ) {
        int a = 0;
        for ( int j = 1; i-j >= 0 && i+j < S.length(); j++ ) {
            if ( S[i-j] == S[i+j] ) { a++; }
        }
        ans = max( ans, 1+a*2  );
        a = 0;
        for ( int j = 0; i-j >= 0 && i+1+j < S.length(); j++ ) {
            if ( S[i-j] == S[i+1+j] ) { a++; }
        }
        ans = max( ans, a*2 );
    }
    cout << ans << endl;
    return 0;
}
            
            
            
        