結果

問題 No.429 CupShuffle
ユーザー aRacaRac
提出日時 2016-11-26 16:19:03
言語 Scala(Beta)
(3.4.0)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 8,980 ms
コンパイル使用メモリ 266,608 KB
実行使用メモリ 93,404 KB
最終ジャッジ日時 2023-09-12 07:41:39
合計ジャッジ時間 30,063 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 956 ms
62,864 KB
testcase_02 WA -
testcase_03 AC 960 ms
62,800 KB
testcase_04 WA -
testcase_05 AC 953 ms
62,696 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 944 ms
62,700 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1,480 ms
85,116 KB
testcase_15 AC 965 ms
62,748 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))
    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