結果

問題 No.679 不思議マーケット
ユーザー cielciel
提出日時 2018-04-30 23:49:28
言語 Ruby
(3.3.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 310 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 11,480 KB
実行使用メモリ 15,608 KB
最終ジャッジ日時 2023-09-10 08:33:46
合計ジャッジ時間 2,532 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,156 KB
testcase_01 AC 79 ms
15,172 KB
testcase_02 AC 79 ms
15,188 KB
testcase_03 AC 91 ms
15,424 KB
testcase_04 AC 84 ms
15,128 KB
testcase_05 AC 88 ms
15,240 KB
testcase_06 AC 82 ms
15,248 KB
testcase_07 AC 82 ms
15,084 KB
testcase_08 AC 84 ms
15,036 KB
testcase_09 AC 79 ms
15,180 KB
testcase_10 AC 80 ms
15,148 KB
testcase_11 AC 82 ms
15,148 KB
testcase_12 AC 82 ms
15,132 KB
testcase_13 AC 83 ms
15,292 KB
testcase_14 AC 82 ms
15,188 KB
testcase_15 AC 83 ms
15,608 KB
testcase_16 AC 80 ms
15,236 KB
testcase_17 AC 80 ms
15,032 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:10: warning: assigned but unused variable - r
Syntax OK

ソースコード

diff #

def cycle(c,m,f,h)
	return f[c] if !f[c].nil?
	f[c]=h[c].all?{|e|
		!m.has_key?(e) && (m[e]=1;k=cycle(e,m,f,h);m.delete e;k)
	}
end
n,m=gets.split.map &:to_i
h=Hash.new{|h,k|h[k]=[]}
m.times{
g,r=gets.split.map &:to_i
h[g]=gets.split.map(&:to_i)
}
f=[nil]*-~n
(1..n).map{|i|cycle(i,{i=>1},f,h)}
p f.count(true)
0