結果

問題 No.556 仁義なきサルたち
ユーザー letrangerjpletrangerjp
提出日時 2017-08-11 23:17:46
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 541 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 19,616 KB
最終ジャッジ日時 2024-04-20 23:33:36
合計ジャッジ時間 9,536 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
17,920 KB
testcase_01 WA -
testcase_02 AC 76 ms
12,288 KB
testcase_03 AC 78 ms
12,288 KB
testcase_04 AC 82 ms
12,288 KB
testcase_05 AC 86 ms
12,160 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 171 ms
12,416 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.take(2).map(&:to_i)
AB = $<.map{|s| s.split.take(2).map(&:to_i).map(&:pred) }

numbers = [1] * N
team = [*0...N]

f = -> a,b{
  to = team[a]
  from = team[b]
  team.map!{|t|
    t == from ? to : t
  }
  sum = numbers[to] + numbers[from]
  numbers[to] = sum
  numbers[from] = sum
}

AB.each{|a, b|
  next if team[a] == team[b]
  if numbers[a] > numbers[b]
    f[a, b]
  elsif numbers[b] > numbers[a]
    f[b, a]
  elsif team[a] < team[b]
    f[a, b]
  else
    f[b, a]
  end
#   p numbers
#   p team
}
puts team.map(&:succ)
0