結果
| 問題 | 
                            No.351 市松スライドパズル
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-01-19 17:40:23 | 
| 言語 | Nim  (2.2.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 41 ms / 2,000 ms | 
| コード長 | 727 bytes | 
| コンパイル時間 | 2,378 ms | 
| コンパイル使用メモリ | 61,372 KB | 
| 実行使用メモリ | 6,784 KB | 
| 最終ジャッジ日時 | 2024-07-01 10:22:06 | 
| 合計ジャッジ時間 | 5,091 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 17 | 
ソースコード
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 = newSeq[int32](n)
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"