結果

問題 No.588 空白と回文
ユーザー ikom
提出日時 2017-11-10 22:10:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 580 bytes
コンパイル時間 802 ms
コンパイル使用メモリ 58,204 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 12:07:04
合計ジャッジ時間 1,586 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {

string s;
int ans = 0,l = 0;

cin >> s;

for(int i = 1;i < s.length();i++){
    l = 0;
    if(s[i] == s[i+1]){
        int j = 1;
        l = 2;
        while(1){
            j++;
            if(s[i-j+1] != s[i+j]) break;
            l += 2;
        }
    }else if(s[i-1] == s[i+1]){
        int j = 1;
        l = 3;
        while(1){
            j++;
            if(s[i-j] != s[i+j]) break;
            l += 2;
        }
    }
    ans = max(l,ans);
}

cout << ans << endl;

return 0;
}
0