結果
問題 | No.588 空白と回文 |
ユーザー |
|
提出日時 | 2017-11-03 22:30:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 570 bytes |
コンパイル時間 | 1,371 ms |
コンパイル使用メモリ | 158,052 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-22 15:56:16 |
合計ジャッジ時間 | 2,246 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <bits/stdc++.h>#define MOD 1000000007LLusing namespace std;typedef long long ll;typedef pair<int,int> P;string str;int dp[1001][1001];int main(void){cin >> str;int n=str.size();int ans=0;for(int i=0;i<n;i++){int now=0;for(int j=0;j<n;j++){if(i-j<0 || i+j>=n)break;if(j==0)now++;else if(str[i-j]==str[i+j])now+=2;}ans=max(ans,now);}for(int i=0;i<n;i++){int now=0;for(int j=0;j<n;j++){if(i-j<0 || i+j+1>=n)break;if(str[i-j]==str[i+j+1])now+=2;}ans=max(ans,now);}printf("%d\n",ans);return 0;}