結果

問題 No.429 CupShuffle
ユーザー むらためむらため
提出日時 2019-01-21 11:05:22
言語 Nim
(2.0.2)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 902 bytes
コンパイル時間 2,901 ms
コンパイル使用メモリ 69,804 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 02:26:47
合計ジャッジ時間 3,863 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 8 ms
4,376 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 8 ms
4,380 KB
testcase_14 AC 8 ms
4,376 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 : array[100010,int32]
var XC: array[100010,int32]
for i in 0.int32..<n.int32: C[i] = i + 1

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])
var diff = newSeq[int]()
for i in 0..<n:
  let d = scan()
  if C[i] == d : continue
  diff &= C[i]
  if diff.len == 2: break
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