結果

問題 No.351 市松スライドパズル
ユーザー むらためむらため
提出日時 2019-01-19 17:53:50
言語 Nim
(2.0.2)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 851 bytes
コンパイル時間 2,244 ms
コンパイル使用メモリ 66,112 KB
実行使用メモリ 5,984 KB
最終ジャッジ日時 2023-09-14 02:19:29
合計ジャッジ時間 4,321 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
5,936 KB
testcase_01 AC 2 ms
4,500 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 32 ms
5,892 KB
testcase_14 AC 31 ms
5,796 KB
testcase_15 AC 34 ms
5,888 KB
testcase_16 AC 31 ms
5,876 KB
testcase_17 AC 27 ms
5,916 KB
testcase_18 AC 28 ms
5,880 KB
testcase_19 AC 30 ms
5,900 KB
testcase_20 AC 30 ms
5,984 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]
var isC: array[1000010,bool]
for i in 0..<n:
  isC[i] = 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')
  ops[i] = k
var x = 0
var y = 0
for i in 1..n:
  let op = ops[n-i]
  if isC[n-i]:
    if x != op: continue
    if y == 0: y = h - 1
    else: y -= 1
  else:
    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