結果

問題 No.588 空白と回文
ユーザー kkty
提出日時 2017-11-04 10:28:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 824 bytes
コンパイル時間 1,476 ms
コンパイル使用メモリ 160,024 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-22 17:06:04
合計ジャッジ時間 2,033 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef int ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 30);
typedef pair<ll,ll> pii;
struct Edge{ ll s,t,c; };
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;

int main() {
  string S; cin>>S;
  ll N=S.length();
  ll ans=0;
  REP(i,N) {
    ll cnt=0;
    for(ll j=1;i+j<N&&i-j>=0;j++) {
      if(S[i+j]==S[i-j]) cnt++;
    }
    ans=max(ans,1+cnt*2);
  }
  REP(i,N-1) {
    ll cnt=0;
    for(ll j=0;i-j>=0&&i+j+1<N;j++)
      if(S[i-j]==S[i+j+1]) cnt++;
    ans=max(ans,cnt*2);
  }
  cout<<ans<<endl;
}
0