結果

問題 No.429 CupShuffle
コンテスト
ユーザー aRac
提出日時 2016-11-26 16:19:03
言語 Scala(Beta)
(3.8.1)
コンパイル:
scalac _filename_
実行:
java -cp .:/home/linuxbrew/.linuxbrew/Cellar/scala/3.8.1/libexec/maven2/org/scala-lang/scala3-library_3/3.8.1/scala3-library_3-3.8.1.jar:/home/linuxbrew/.linuxbrew/Cellar/scala/3.8.1/libexec/maven2/org/scala-lang/scala-library/3.8.1/scala-library-3.8.1.jar _class_
結果
WA  
実行時間 -
コード長 731 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 11,539 ms
コンパイル使用メモリ 270,720 KB
実行使用メモリ 88,596 KB
最終ジャッジ日時 2026-03-09 14:57:06
合計ジャッジ時間 22,271 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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