結果

問題 No.351 市松スライドパズル
ユーザー GrayCoderGrayCoder
提出日時 2018-05-27 08:25:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 564 ms / 2,000 ms
コード長 855 bytes
コンパイル時間 1,489 ms
コンパイル使用メモリ 10,748 KB
実行使用メモリ 78,928 KB
最終ジャッジ日時 2023-09-11 03:49:58
合計ジャッジ時間 7,237 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,792 KB
testcase_01 AC 16 ms
7,896 KB
testcase_02 AC 16 ms
7,904 KB
testcase_03 AC 17 ms
7,796 KB
testcase_04 AC 16 ms
7,900 KB
testcase_05 AC 16 ms
7,780 KB
testcase_06 AC 16 ms
7,780 KB
testcase_07 AC 16 ms
7,832 KB
testcase_08 AC 16 ms
7,844 KB
testcase_09 AC 16 ms
7,776 KB
testcase_10 AC 16 ms
7,872 KB
testcase_11 AC 16 ms
7,776 KB
testcase_12 AC 16 ms
7,900 KB
testcase_13 AC 554 ms
77,264 KB
testcase_14 AC 548 ms
77,596 KB
testcase_15 AC 561 ms
78,756 KB
testcase_16 AC 564 ms
78,732 KB
testcase_17 AC 512 ms
78,864 KB
testcase_18 AC 514 ms
78,852 KB
testcase_19 AC 560 ms
78,856 KB
testcase_20 AC 557 ms
78,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def main():
    H, W = map(int, input().split())
    if H == W == 1:
        print('white')
        return
    N = int(input())
    S = sys.stdin.readlines()

    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:
        n = n.rstrip()
        if n == 'R ' + str(row):
            col = col - 1 if col > 0 else W - 1
        elif n == 'C ' + str(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)
    i = 1 if i else 0
    color = ('white', 'black')
    print(color[i])

main()
0