結果

問題 No.429 CupShuffle
ユーザー むらため
提出日時 2019-01-21 10:51:09
言語 Nim
(2.2.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 776 bytes
コンパイル時間 2,976 ms
コンパイル使用メモリ 66,256 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-01 10:28:33
合計ジャッジ時間 4,135 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,strutils
template times*(n:int,body) = (for _ in 0..<n: body)

proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    var k = getchar_unlocked()
    if k < '0': break
    result = 10 * result + k.ord - '0'.ord

let n = scan()
let k = scan()
let x = scan()
var C = toSeq(1..n)
var XC : seq[int]
for ik in 1..k:
  if ik == x :
    XC = C
    4.times : discard getchar_unlocked()
    continue
  let a = scan() - 1
  let b = scan() - 1
  swap(C[a],C[b])
let D = newSeqWith(n,scan())
let diff = toSeq(0..<n).filterIt(C[it] != D[it]).mapIt(C[it])
var answers = newSeq[int]()
for i,xc in XC:
  if xc notin diff : continue
  answers &= i + 1
  if answers.len == 2: break
echo answers.mapIt($it).join(" ")
0