結果

問題 No.437 cwwゲーム
ユーザー suppy193
提出日時 2016-11-02 13:22:46
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 668 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-11-25 01:26:41
合計ジャッジ時間 4,978 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - score
Syntax OK

ソースコード

diff #

a = gets.strip.split('').map(&:to_i)
#p a
score = 0
@max_score = 0

def dfs(a, score)
	(0...a.length).to_a.combination(3) do |set|
		#p set
		#p a
		subscore = 0
		if a[set[0]] != a[set[1]] && a[set[1]] == a[set[2]]
			#print "#{a[set[0]]}#{a[set[1]]}#{a[set[2]]}\n"
			subscore = (a[set[0]].to_s + a[set[1]].to_s + a[set[2]].to_s).to_i
			#p score + subscore
			if score + subscore > @max_score
				@max_score = score + subscore
			end
			next_a = a.clone
			#p set
			set.each do |index|
				#p next_a
				#print "index #{index}\n"
				next_a[index] = nil
			end
			next_a.compact!
			#p next_a
			dfs(next_a, score + subscore)
		end
	end
end

dfs(a, 0)
p @max_score
0