結果

問題 No.588 空白と回文
ユーザー masamasa
提出日時 2017-11-04 00:16:50
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 313 ms / 2,000 ms
コード長 474 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 69,900 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-23 15:28:07
合計ジャッジ時間 2,841 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.size();

	int ans = 0;

	for (int l = 0; l < n; l++) {
		for (int r = l; r < n; r++) {
			int tmp = 0;
			for (int i = 0; l + i <= r - i; i++) {
				if (s[l + i] == s[r - i]) {
					tmp += l + i == r - i ? 1 : 2;
				}
			}
			ans = max(ans, tmp);
		}
	}

	cout << ans << endl;
	return 0;
}
0