結果

問題 No.2301 Namorientation
ユーザー simansiman
提出日時 2023-05-16 13:38:07
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 506 bytes
コンパイル時間 129 ms
コンパイル使用メモリ 11,260 KB
実行使用メモリ 92,652 KB
最終ジャッジ日時 2023-08-21 05:23:52
合計ジャッジ時間 28,971 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,252 KB
testcase_01 AC 78 ms
15,180 KB
testcase_02 AC 78 ms
15,256 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 78 ms
15,084 KB
testcase_09 AC 77 ms
15,116 KB
testcase_10 AC 78 ms
15,304 KB
testcase_11 AC 78 ms
15,168 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 575 ms
47,052 KB
testcase_26 AC 701 ms
53,688 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i

O = Hash.new { |h, k| h[k] = {} }
E = Array.new(N + 1) { [] }
OE = []

N.times do
  a, b = gets.split.map(&:to_i)
  E[a] << b
  E[b] << a
  OE << [a, b]
end

def dfs(v, par, visited)
  return if visited[v]
  visited[v] = true

  if par
    O[par][v] = 1
  end

  E[v].each do |u|
    dfs(u, v, visited)
  end
end

visited = Array.new(N + 1, false)
1.upto(N) do |v|
  next if visited[v]

  dfs(v, nil, visited)
end

OE.each do |a, b|
  if O[a][b]
    puts '<-'
  else
    puts '->'
  end
end
0