結果

問題 No.273 回文分解
ユーザー wahr69wahr69
提出日時 2015-08-28 23:01:04
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,123 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 00:09:52
合計ジャッジ時間 2,356 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 WA -
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 WA -
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

#include <array>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#include <string>
#include <sstream>

#include <memory>
#include <cassert>

#include <functional>

using namespace std;

const int MOD = 1000000007;

typedef unsigned long long ull;

int main()
{
	string s;
	cin >> s;

	if (s.size() == 2) {
		cout << 1 << endl;
		return 0;
	}

	for (int len = s.size(); len >= 2; --len) { // 文字数
		for (int j = 0; j < s.size() - len + 1; ++j) { // 開始位置
			bool isKaibun = false;
			int count = 1;
			for (int k = j; true; ++k) { // 今の位置
				int back = j + len - count;
				if (k == back) {
					isKaibun = true;
					break;
				}
				if (k + 1 == back) {
					if (s[k] == s[back]) {
						isKaibun = true;
					} else {
						isKaibun = false;
					}
					break;
				}
				if (s[k] != s[back]) {
					isKaibun = false;
					break;
				}
				++count;
			}
			if (isKaibun) {
				cout << len << endl;
				return 0;
			}
		}
	}

	cout << 1 << endl;
	return 0;
}
0