結果

問題 No.429 CupShuffle
ユーザー むらためむらため
提出日時 2019-01-21 10:51:09
言語 Nim
(2.0.2)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 776 bytes
コンパイル時間 4,560 ms
コンパイル使用メモリ 69,676 KB
実行使用メモリ 7,828 KB
最終ジャッジ日時 2023-09-14 02:26:17
合計ジャッジ時間 4,079 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 11 ms
7,828 KB
testcase_12 AC 9 ms
7,552 KB
testcase_13 AC 10 ms
7,604 KB
testcase_14 AC 10 ms
7,620 KB
testcase_15 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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