結果
| 問題 | No.679 不思議マーケット |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-04-30 23:29:21 |
| 言語 | Ruby (4.0.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 412 bytes |
| 記録 | |
| コンパイル時間 | 187 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 14,464 KB |
| 最終ジャッジ日時 | 2024-06-28 00:00:16 |
| 合計ジャッジ時間 | 3,507 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 18 |
コンパイルメッセージ
Main.rb:21: warning: assigned but unused variable - r Syntax OK
ソースコード
#!/usr/bin/ruby
def cycle(c,m,f,h)
return f[c] if f[c]!=nil
q=true
h[c].each{|e|
if f[e].nil?
if m.has_key?(e)
q=false
else
m[e]=1
q=false if !cycle(e,m,f,h)
m.delete e
end
end
}
f[c]=q
end
n,m=gets.split.map &:to_i
h=Hash.new{|h,k|h[k]=[]}
m.times{
g,r=gets.split.map &:to_i
gets.split.map(&:to_i).each{|e|h[g-1]<<e-1}
}
f=[nil]*n
n.times{|i|cycle(i,{i=>1},f,h);p f}
p f.count