結果
問題 | No.74 貯金箱の退屈 |
ユーザー |
![]() |
提出日時 | 2021-06-25 06:24:53 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 94 ms / 5,000 ms |
コード長 | 683 bytes |
コンパイル時間 | 74 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-06-25 07:38:51 |
合計ジャッジ時間 | 4,457 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
コンパイルメッセージ
Syntax OK
ソースコード
N = gets.to_iD = gets.split.map(&:to_i)W = gets.split.map(&:to_i)E = Hash.new { |h, k| h[k] = {} }O = Hash.new(false)D.each_with_index do |d, i|u = (i + d) % Nv = (i - d) % NO[u] = true if u == vE[u][v] = trueE[v][u] = trueendvisited = Hash.new(false)all_ok = trueN.times do |u|next if visited[u]queue = []queue << uura_cnt = 0one = falseuntil queue.empty?u = queue.shiftnext if visited[u]visited[u] = trueura_cnt += 1 if W[u] == 0one = true if O[u]E[u].each_key do |v|queue << vendendif ura_cnt.odd? && !oneall_ok = falseendendif all_okputs 'Yes'elseputs 'No'end