結果

問題 No.2837 Flip Triomino
ユーザー suo
提出日時 2024-07-26 17:18:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 781 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 82,392 KB
実行使用メモリ 78,664 KB
最終ジャッジ日時 2024-07-26 17:18:55
合計ジャッジ時間 4,900 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 14 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = map(int, input().split())
s = [input() for i in range(h)]

assert 3 <= h <= 500 and 3 <= w <= 500
for i in range(h):
    for j in range(w):
        assert s[i][j] in ["W", "B", "?"]

q_cnt = [0] * 3
b_cnt = [0] * 3
mod = 998244353

for i in range(h):
    for j in range(w):
        if s[i][j] == "B":
            b_cnt[(i + j) % 3] += 1
        if s[i][j] == "?":
            print(i, j)
            q_cnt[(i + j) % 3] += 1


ans_o = 1
ans_e = 1
for b, q in zip(b_cnt, q_cnt):
    if b & 1:
        ans_e *= 0 if not q else pow(2, q - 1, mod)
        ans_o *= 1 if not q else pow(2, q - 1, mod)
    else:
        ans_e *= 1 if not q else pow(2, q - 1, mod)
        ans_o *= 0 if not q else pow(2, q - 1, mod)

    ans_e %= mod
    ans_o %= mod

print((ans_e + ans_o) % mod)
0