結果
問題 | No.351 市松スライドパズル |
ユーザー |
|
提出日時 | 2019-01-19 17:46:51 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 869 bytes |
コンパイル時間 | 2,157 ms |
コンパイル使用メモリ | 61,404 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-01 10:22:27 |
合計ジャッジ時間 | 3,831 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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: 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 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"