結果
問題 | No.588 空白と回文 |
ユーザー |
|
提出日時 | 2020-05-01 10:14:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 388 bytes |
コンパイル時間 | 1,908 ms |
コンパイル使用メモリ | 193,684 KB |
最終ジャッジ日時 | 2025-01-10 03:55:50 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int main(){ string s; cin>>s; int n=s.length(); int ans=0; rep(i,n){ int cnt=1; for(int d=1;0<=i-d&&i+d<n;d++) if(s[i-d]==s[i+d]) cnt+=2; ans=max(ans,cnt); cnt=0; for(int d=1;0<=i-d&&i+d-1<n;d++) if(s[i-d]==s[i+d-1]) cnt+=2; ans=max(ans,cnt); } printf("%d\n",ans); return 0; }