結果

問題 No.273 回文分解
ユーザー suppy193suppy193
提出日時 2017-02-06 13:12:29
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 429 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 11,384 KB
実行使用メモリ 15,416 KB
最終ジャッジ日時 2023-08-25 22:57:45
合計ジャッジ時間 4,514 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 80 ms
15,136 KB
testcase_04 AC 80 ms
15,160 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 80 ms
15,304 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 80 ms
15,244 KB
testcase_16 AC 78 ms
15,260 KB
testcase_17 AC 79 ms
15,092 KB
testcase_18 WA -
testcase_19 AC 80 ms
15,052 KB
testcase_20 AC 79 ms
15,092 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 104 ms
15,288 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 79 ms
15,128 KB
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def search(s, s_len, len_max, num)
	return if len_max > s_len && len_max < @len_max
	if s_len == 0 && num > 1
		@len_max = [@len_max, len_max].max
		return
	end
	(1...s_len).each do |i|
		if s[0..i] == s[0..i].reverse
			len_max = [len_max, i + 1].max
			search(s[i + 1..-1], s_len - (i + 1), len_max, num + 1)
		end
	end
end

s = gets.strip
@len_max = 0
if s.length == 2
	puts '1'
else
	search(s, s.length, 0, 0)
	p @len_max
end
0