結果
問題 | No.273 回文分解 |
ユーザー |
|
提出日時 | 2015-08-28 22:34:07 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 565 bytes |
コンパイル時間 | 516 ms |
コンパイル使用メモリ | 61,120 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-25 13:24:27 |
合計ジャッジ時間 | 1,670 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <iostream>#include <cstdio>#include <vector>#include <algorithm>#include <utility>#include <string>using namespace std;int check(string s, int a, int b) {int len = b - a + 1;while (a <= b) {if (s[a] != s[b]) {return 0;}a++;b--;}return len;}int main() {string s;cin >> s;int n = s.size();int max_len = 0, n_len;for (int i = 0; i < n; i++) {for (int j = i; j < n; j++) {n_len = check(s, i, j);if (n_len < n) {max_len = max(max_len, n_len);}}}cout << max_len << endl;return 0;}