結果

問題 No.273 回文分解
ユーザー cureskol
提出日時 2020-04-15 00:06:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 393 bytes
コンパイル時間 1,571 ms
コンパイル使用メモリ 167,980 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-01 18:27:02
合計ジャッジ時間 2,673 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}

signed main(){
  string s;cin>>s;
  int ans=0;
  for(int i=0;i<s.size();i++){
    for(int j=1;i+j<=s.size();j++){
      if(j==s.size())continue;
      string t=s.substr(i,j);
      string u=t;
      reverse(t.begin(),t.end());
      if(t==u)chmax(ans,j);
    }
  }
  cout<<ans<<endl;
}
0