結果

問題 No.429 CupShuffle
ユーザー aRacaRac
提出日時 2016-11-26 16:24:39
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 1,511 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 8,900 ms
コンパイル使用メモリ 256,936 KB
実行使用メモリ 93,040 KB
最終ジャッジ日時 2023-09-12 07:45:03
合計ジャッジ時間 28,908 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,011 ms
63,540 KB
testcase_01 AC 965 ms
62,792 KB
testcase_02 AC 969 ms
62,668 KB
testcase_03 AC 973 ms
62,792 KB
testcase_04 AC 1,012 ms
63,124 KB
testcase_05 AC 973 ms
63,108 KB
testcase_06 AC 1,004 ms
63,100 KB
testcase_07 AC 1,001 ms
62,828 KB
testcase_08 AC 968 ms
62,708 KB
testcase_09 AC 994 ms
63,120 KB
testcase_10 AC 1,213 ms
63,596 KB
testcase_11 AC 1,479 ms
93,040 KB
testcase_12 AC 1,471 ms
87,836 KB
testcase_13 AC 1,511 ms
89,632 KB
testcase_14 AC 1,487 ms
85,004 KB
testcase_15 AC 965 ms
62,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

object Main {
  def swap(n: Int, m: Int, arr: Array[Int]): Unit = {
      val tmp = arr(n)
      arr(n) = arr(m)
      arr(m) = tmp
  }

  def main(args: Array[String]) = {
    val in = io.Source.stdin.getLines.toList
    val Array(n, k, x) = in(0).split(" ").map(_.toInt)
    val pre_step = in.slice(1, x).map(_.split(" ").map(_.toInt))
    val post_step = in.slice(x+1, k+1).map(_.split(" ").map(_.toInt)).reverse
    val pre = (1 to n).toArray
    for (Array(a, b) <- pre_step) {
        swap(a-1, b-1, pre)
    }
    val post = in.last.split(" ").map(_.toInt)
    for (Array(a, b) <- post_step) {
        swap(a-1, b-1, post)
    }
    val ans = for (i <- 0 until n if pre(i) != post(i)) yield i+1
    println(ans.mkString(" "))
  }
}
0