結果

問題 No.351 市松スライドパズル
ユーザー むらためむらため
提出日時 2019-01-19 17:42:57
言語 Nim
(2.0.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 2,243 ms
コンパイル使用メモリ 67,044 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2023-09-14 02:18:41
合計ジャッジ時間 4,050 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
6,912 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 34 ms
6,864 KB
testcase_14 AC 35 ms
6,932 KB
testcase_15 AC 35 ms
6,948 KB
testcase_16 AC 35 ms
6,912 KB
testcase_17 AC 26 ms
6,936 KB
testcase_18 AC 27 ms
6,800 KB
testcase_19 AC 34 ms
6,864 KB
testcase_20 AC 34 ms
6,912 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,int32]
for i in 0..<n:
  let isC = getchar_unlocked() == 'C'
  discard getchar_unlocked()
  let k = scan()
  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
  op = op.abs - 1
  if isC:
    if x != op: continue
    y = (y - 1 + h) mod h
  else:
    if y != op: continue
    x = (x - 1 + w) mod w

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