結果

問題 No.351 市松スライドパズル
ユーザー GrayCoderGrayCoder
提出日時 2018-05-25 20:53:27
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 828 bytes
コンパイル時間 346 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 257,012 KB
最終ジャッジ日時 2024-06-28 18:05:07
合計ジャッジ時間 10,762 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 8 RE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    H, W = map(int, input().split())
    N = int(input())
    S = [(i, int(j)) for i, j in (input().split() for _ in [0] * N)]

    if H == W == 1:
        print('white')
        return

    if W == 1:
        even = 0
        odd = 1
    else:
        n = W // 2
        if W % 2:
            even = int('01' * n + '0', 2)
            odd = int('10' * n + '1', 2)
        else:
            even = int('01' * n, 2)
            odd = int('10' * n, 2)
    S.reverse()
    col, row = 0, 0
    for n in S:
        if n == ('R', row):
            col = col - 1 if col > 0 else W - 1
        elif n == ('C', col):
            row = row - 1 if row > 0 else H - 1
    n = W - 1 - col
    if row % 2:
        i = odd & (2 ** n)
    else:
        i = even & (2 ** n)
    color = ('white', 'black')
    print(color[i])

main()
0