結果
| 問題 | No.588 空白と回文 | 
| コンテスト | |
| ユーザー |  kurenai3110 | 
| 提出日時 | 2017-11-03 22:36:16 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 2,000 ms | 
| コード長 | 669 bytes | 
| コンパイル時間 | 506 ms | 
| コンパイル使用メモリ | 61,872 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-22 15:59:50 | 
| 合計ジャッジ時間 | 1,193 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 25 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int solve1(string S, int i) {
	int ans = 1;
	for (int j = 1;; j++) {
		if (i - j < 0 || i + j >= S.size())break;
		if (S[i - j] == S[i + j])ans += 2;
	}
	return ans;
}
int solve2(string S, int i) {
	int ans = 0;
	for (int j = 1;; j++) {
		if (i - j < 0 || i + j > S.size())break;
		if (S[i - j] == S[i + j - 1])ans += 2;
	}
	return ans;
}
int main()
{
	string S; cin >> S;
	int ans = 1;
	for(int i=0;i<S.size();i++){
		ans = max(ans, solve1(S, i));
	}
	for (int i = 1; i< S.size(); i++) {
		ans = max(ans, solve2(S, i));
	}
	cout << ans << endl;
    return 0;
}
            
            
            
        