結果

問題 No.429 CupShuffle
ユーザー simansiman
提出日時 2020-12-23 18:24:27
言語 Ruby
(3.3.0)
結果
AC  
実行時間 380 ms / 2,000 ms
コード長 422 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 11,900 KB
実行使用メモリ 31,956 KB
最終ジャッジ日時 2023-10-21 15:14:46
合計ジャッジ時間 4,297 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
16,092 KB
testcase_01 AC 86 ms
16,092 KB
testcase_02 AC 87 ms
16,092 KB
testcase_03 AC 87 ms
16,092 KB
testcase_04 AC 90 ms
16,092 KB
testcase_05 AC 87 ms
16,092 KB
testcase_06 AC 89 ms
16,092 KB
testcase_07 AC 89 ms
16,092 KB
testcase_08 AC 87 ms
16,092 KB
testcase_09 AC 89 ms
16,092 KB
testcase_10 AC 114 ms
17,380 KB
testcase_11 AC 380 ms
31,952 KB
testcase_12 AC 371 ms
31,956 KB
testcase_13 AC 372 ms
31,956 KB
testcase_14 AC 380 ms
31,948 KB
testcase_15 AC 87 ms
16,092 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K, X = gets.split.map(&:to_i)
Q = K.times.map { 
  a, b = gets.chomp.split

  if a == '?'
    [-1, -1]
  else
    [a.to_i - 1, b.to_i - 1]
  end
}
A = [*1..N]
C = gets.split.map(&:to_i)

Q.each do |a, b|
  break if a == -1

  A[a], A[b] = A[b], A[a]
end

Q.reverse_each do |a, b|
  break if a == -1

  C[a], C[b] = C[b], C[a]
end

ans = []

N.times do |i|
  next if A[i] == C[i]

  ans << i + 1
end

puts ans.join(' ')
0