結果

問題 No.346 チワワ数え上げ問題
ユーザー suppy193
提出日時 2016-04-11 13:43:44
言語 Ruby
(3.4.1)
結果
RE  
実行時間 -
コード長 491 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 20,128 KB
最終ジャッジ日時 2024-10-04 06:05:00
合計ジャッジ時間 6,407 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 10 RE * 4 TLE * 1 -- * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def dfs(s, cww)
	if cww == "cww"
		@count += 1
		return
	end
	return if s.length == 0
	if cww == ""
		if s[0] == "c"
			dfs(s[1..-1], "c")
			dfs(s[1..-1], "")
		else
			dfs(s[1..-1], "")
		end
	elsif cww == "c"
		if s[0] == "w"
			dfs(s[1..-1], "cw")
			dfs(s[1..-1], "c")
		else
			dfs(s[1..-1], "c")
		end
	elsif cww == "cw"
		if s[0] == "w"
			dfs(s[1..-1], "cww")
			dfs(s[1..-1], "cw")
		else
			dfs(s[1..-1], "cw")
		end
	end
end

@count = 0
s = gets.strip
#puts s
dfs(s, "")
p @count
0