結果

問題 No.123 カードシャッフル
ユーザー むらためむらため
提出日時 2019-01-17 04:58:46
言語 Nim
(2.0.0)
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 738 bytes
コンパイル時間 2,365 ms
コンパイル使用メモリ 69,084 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 22:27:27
合計ジャッジ時間 3,147 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

import sequtils
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  result = 0
  while true:
    var k = getchar_unlocked()
    if k < '0' or k > '9': break
    else: result = 10 * result + k.ord - '0'.ord
# type
#   NodeObj[T] = object
#     next : ref NodeObj[T]
#     value : T
#   Node[T] = ref NodeObj[T]
#   ConstantList[T] = ref object
#     nodes: seq[Node[T]]

# proc initConstantList[T](arr:seq[T]) : List[T] =
#   new(result)
#   for a in arr:
#   result.nodes =


let n = scan()
let m = scan()
var C = toSeq(1..n)
for _ in 0..<m:
  let a = scan()
  let head = C[a-1]
  for i in (a-1).countdown(1): C[i] = C[i-1]
  C[0] = head
  # C = C[a-1] & C[0..<a-1] & C[a..^1]
echo C[0]
0