結果

問題 No.588 空白と回文
コンテスト
ユーザー zengyongxu-jerry
提出日時 2026-08-25 20:35:14
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.90.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
+ 11µs
コード長 909 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,971 ms
コンパイル使用メモリ 350,684 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-25 20:35:25
合計ジャッジ時間 5,370 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// <DATETIME>
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>
#define fi first
#define se second
#define rep(i, x, y) for (int i = (x); i <= (y); i ++ )
#define per(i, x, y) for (int i = (x); i >= (y); i -- )
const int N = 5e5 + 5, M = 1e6 + 5;
const int inf = 1e9, mod = 998244353;
const ll INF = 1e18, RMX = 2324814;
mt19937 rd(time(0));
uniform_int_distribution<int> dist(0, RMX);

string s;

signed main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    cin >> s; int n = s.size();
    
    int res = 0;
    rep(i, 1, n){
		int qwq = -1;
		int l = i, r = i;
		while (l >= 1 && r <= n) qwq += (s[l - 1] == s[r - 1]) * 2, l --, r ++ ;
		res = max(res, qwq);
	}
	rep(i, 1, n - 1){
		int qwq = 0;
		int l = i, r = i + 1;
		while (l >= 1 && r <= n) qwq += (s[l - 1] == s[r - 1]) * 2, l --, r ++ ;
		res = max(res, qwq);
	}
	cout << res << "\n";
}
0