結果

問題 No.273 回文分解
ユーザー not_522
提出日時 2015-09-08 20:42:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 356 bytes
コンパイル時間 1,334 ms
コンパイル使用メモリ 160,380 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-25 13:29:23
合計ジャッジ時間 2,288 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  string s;
  cin >> s;
  const int n = s.size();
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 1; i + j <= n && j < n; ++j) {
      string ss = s.substr(i, j), r = ss;
      reverse(r.begin(), r.end());
      if (ss == r) res = max(res, j);
    }
  }
  cout << res << endl;
}
0