結果

問題 No.429 CupShuffle
ユーザー shi-moshi-mo
提出日時 2016-10-03 00:15:18
言語 Ruby
(3.3.0)
結果
AC  
実行時間 310 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 54 ms
コンパイル使用メモリ 11,512 KB
実行使用メモリ 28,264 KB
最終ジャッジ日時 2023-08-27 06:36:38
合計ジャッジ時間 3,483 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,136 KB
testcase_01 AC 76 ms
15,120 KB
testcase_02 AC 76 ms
15,036 KB
testcase_03 AC 76 ms
15,132 KB
testcase_04 AC 80 ms
15,200 KB
testcase_05 AC 82 ms
15,040 KB
testcase_06 AC 79 ms
15,164 KB
testcase_07 AC 79 ms
15,272 KB
testcase_08 AC 78 ms
15,128 KB
testcase_09 AC 80 ms
15,128 KB
testcase_10 AC 99 ms
16,088 KB
testcase_11 AC 300 ms
28,264 KB
testcase_12 AC 299 ms
27,824 KB
testcase_13 AC 306 ms
28,264 KB
testcase_14 AC 310 ms
27,612 KB
testcase_15 AC 78 ms
15,148 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - x
Syntax OK

ソースコード

diff #

n, k, x = gets.split.map(&:to_i)
swap = []
k.times do
  swap <<  gets.split.map(&:to_i)
end
c = gets.split.map(&:to_i)

s = (1..n).to_a
k.times do
  a, b = swap.shift
  break if 0 == a
  t = s[a-1]
  s[a-1] = s[b-1]
  s[b-1] = t
end

swap.reverse.each do |a, b|
  t = c[a-1]
  c[a-1] = c[b-1]
  c[b-1] = t
end

ax = []
n.times do |i|
  next if c[i] == s[i]
  ax << i+1
end
puts ax.sort.join(' ')
0