結果

問題 No.226 0-1パズル
ユーザー hotcoffeehotcoffee
提出日時 2024-03-15 07:20:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,009 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2024-03-15 07:20:21
合計ジャッジ時間 2,417 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
9,984 KB
testcase_01 AC 27 ms
9,984 KB
testcase_02 WA -
testcase_03 AC 27 ms
9,984 KB
testcase_04 AC 29 ms
9,984 KB
testcase_05 WA -
testcase_06 AC 29 ms
9,984 KB
testcase_07 WA -
testcase_08 AC 28 ms
9,984 KB
testcase_09 AC 26 ms
9,984 KB
testcase_10 AC 28 ms
9,984 KB
testcase_11 AC 27 ms
9,984 KB
testcase_12 AC 27 ms
9,984 KB
testcase_13 WA -
testcase_14 AC 26 ms
9,984 KB
testcase_15 AC 26 ms
9,984 KB
testcase_16 WA -
testcase_17 AC 30 ms
9,984 KB
testcase_18 AC 29 ms
9,984 KB
testcase_19 AC 28 ms
9,984 KB
testcase_20 AC 26 ms
9,984 KB
testcase_21 AC 30 ms
9,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
table = {}
for i in range(H):
    for j, v in enumerate(list(input())):
        if v != '?':
            if i not in table:
                table[i] = {}
            table[i][j] = int(v)

exp1= H
exp2= W
dup = 2
chk = -1
v_chk = [-1] * W
for i, row in table.items():
    h_chk = -1
    for j, v in row.items():
        if chk == -1:
            chk = (i + j + v) % 2
            dup = 1
        else:
            if chk != (i + j + v) % 2:
                dup = 0
        if h_chk == -1:
            h_chk = (j + v) % 2
            exp1 -= 1
        else:
            if h_chk != (j + v) % 2:
                exp1 = -1
        if v_chk[j] == -1:
            v_chk[j] = (i + v) % 2
            exp2 -= 1
        else:
            if v_chk[j] != (i + v) % 2:
                exp2 = -1
    if exp1 == -1 and exp2 == -1:
        break

MOD = 1000000007
ans = 0
if exp1 != -1:
    ans += pow(2, exp1, MOD)
if exp2 != -1:
    ans += pow(2, exp2, MOD) - dup
    ans %= MOD
print(ans)
0