結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 10 ms
4,376 KB
testcase_14 AC 9 ms
4,384 KB
testcase_15 AC 2 ms
4,376 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(): int32 =
  while true:
    var k = getchar_unlocked()
    if k < '0': break
    result = 10 * result + k.ord.int32 - '0'.ord.int32

let n = scan()
let k = scan()
let x = scan()
var C = toSeq(1.int32..n.int32)
var XC : seq[int32]
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 diff = C.filterIt(it != scan())
var answers = newSeq[int]()
for i,xc in XC:
  if xc != diff[0] and xc != diff[1] : continue
  answers &= i + 1
  if answers.len == 2: break
echo answers.mapIt($it).join(" ")
0