結果
問題 |
No.429 CupShuffle
|
ユーザー |
|
提出日時 | 2016-11-26 16:24:39 |
言語 | Scala(Beta) (3.6.2) |
結果 |
AC
|
実行時間 | 1,426 ms / 2,000 ms |
コード長 | 739 bytes |
コンパイル時間 | 8,800 ms |
コンパイル使用メモリ | 260,788 KB |
実行使用メモリ | 90,008 KB |
最終ジャッジ日時 | 2024-06-29 20:39:22 |
合計ジャッジ時間 | 27,644 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
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(" ")) } }