結果
問題 | No.588 空白と回文 |
ユーザー |
|
提出日時 | 2019-08-18 22:02:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 562 bytes |
コンパイル時間 | 2,289 ms |
コンパイル使用メモリ | 192,680 KB |
最終ジャッジ日時 | 2025-01-07 14:13:11 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { string s; cin>>s; int n=s.size(); int ans=0; for (int i=0;i<n;i++) { int l,r; l=i-1; r=i+1; int len=1; while (0<=l&&r<n) { if (s[l]==s[r])len+=2; l--,r++; } ans=max(ans,len); l=i; r=i+1; len=0; while (0<=l&&r<n) { if (s[l]==s[r])len+=2; l--,r++; } ans=max(ans,len); } cout<<ans<<endl; return 0; }