結果
問題 | No.273 回文分解 |
ユーザー |
|
提出日時 | 2015-08-28 22:39:45 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 637 bytes |
コンパイル時間 | 1,343 ms |
コンパイル使用メモリ | 160,252 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-25 13:24:47 |
合計ジャッジ時間 | 2,308 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h>#define rep(i, a) rep2 (i, 0, a)#define rep2(i, a, b) for (int i = (a); i < (b); i++)#define repr(i, a) repr2 (i, 0, a)#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)using namespace std;typedef long long ll;bool ispal(string s) {rep (i, s.length()) {if (s[i] != s[s.length() - 1 - i]) return false;}return true;}int main() {string s;cin >> s;int ans = 1;rep (i, s.length()) {rep2 (j, i, s.length()) {if (i == 0 && j == s.length() - 1) continue;if (ispal(s.substr(i, j - i + 1))) {ans = max(ans, j - i + 1);}}}cout << ans << endl;return 0;}