結果

問題 No.351 市松スライドパズル
ユーザー FromBooskaFromBooska
提出日時 2023-02-28 21:58:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 854 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 86,880 KB
実行使用メモリ 248,588 KB
最終ジャッジ日時 2023-10-14 04:27:28
合計ジャッジ時間 11,177 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 715 ms
183,952 KB
testcase_01 AC 73 ms
70,988 KB
testcase_02 AC 73 ms
71,072 KB
testcase_03 AC 71 ms
71,124 KB
testcase_04 AC 73 ms
71,072 KB
testcase_05 AC 76 ms
71,080 KB
testcase_06 AC 73 ms
71,076 KB
testcase_07 AC 74 ms
71,156 KB
testcase_08 AC 74 ms
71,184 KB
testcase_09 AC 74 ms
71,240 KB
testcase_10 AC 75 ms
71,112 KB
testcase_11 AC 76 ms
71,216 KB
testcase_12 AC 74 ms
71,312 KB
testcase_13 AC 829 ms
245,560 KB
testcase_14 AC 835 ms
245,636 KB
testcase_15 AC 854 ms
248,144 KB
testcase_16 AC 850 ms
248,588 KB
testcase_17 AC 840 ms
242,492 KB
testcase_18 AC 832 ms
238,988 KB
testcase_19 AC 840 ms
248,360 KB
testcase_20 AC 831 ms
248,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 愚直シミュレーションは間に合わない
# 公式解説より
# 全盤面をシミュレートするのは間に合わない
# (0, 0)を戻していってどこにあったのかを調べる

H, W = map(int, input().split())
query = []
N = int(input())
for i in range(N):
    s, k = map(str, input().split())
    query.append((s, int(k)))
    
#print(query)

current = (0, 0)

for i in range(N):
    h, w = current
    s, k = query[-1-i]
    if s == 'R':
        if k == h:
            current = (h, (w-1)%W)
    elif s == 'C':
        if k == w:
            current = ((h-1)%H, w)
    #print(s, k, current)

h, w = current
if (h+w)%2 == 0:
    print('white')
else:
    print('black')
0