結果

問題 No.351 市松スライドパズル
ユーザー むらためむらため
提出日時 2019-01-19 17:50:06
言語 Nim
(2.0.2)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 912 bytes
コンパイル時間 2,375 ms
コンパイル使用メモリ 66,228 KB
実行使用メモリ 5,020 KB
最終ジャッジ日時 2023-09-14 02:18:50
合計ジャッジ時間 4,062 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
4,960 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 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 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 38 ms
4,912 KB
testcase_14 AC 38 ms
4,880 KB
testcase_15 AC 39 ms
4,884 KB
testcase_16 AC 39 ms
4,988 KB
testcase_17 AC 27 ms
5,020 KB
testcase_18 AC 28 ms
4,944 KB
testcase_19 AC 37 ms
4,948 KB
testcase_20 AC 37 ms
4,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 h = scan()
let w = scan()
let n = scan()
var ops: array[1000010,int16]
for i in 0..<n:
  let isC = getchar_unlocked() == 'C'
  discard getchar_unlocked()
  var k = cast[int16](0)
  while true:
    var c = getchar_unlocked()
    if c < '0': break
    k = cast[int16](10) * k + cast[int16](c) - cast[int16]('0')
  if isC : ops[i] = k+1
  else: ops[i] = -k-1
var x = 0
var y = 0
for i in (n-1).countdown(0):
  var op = ops[i]
  let isC = op > 0
  if isC:
    op -= 1
    if x != op: continue
    if y == 0: y = h - 1
    else: y -= 1
  else:
    op = -op - 1
    if y != op: continue
    if x == 0: x = w - 1
    else: x -= 1

if (x mod 2) == (y mod 2) : echo "white"
else:echo "black"
0