結果
問題 |
No.226 0-1パズル
|
ユーザー |
![]() |
提出日時 | 2024-03-14 09:07:18 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 32 ms / 5,000 ms |
コード長 | 1,141 bytes |
コンパイル時間 | 108 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-09-29 23:39:24 |
合計ジャッジ時間 | 1,572 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
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 = {} for i, row in table.items(): h_chk = -1 for j, v in row.items(): if dup != 0: if chk == -1: chk = (i + j + v) % 2 dup = 1 else: if chk != (i + j + v) % 2: dup = 0 if exp1 != -1: if h_chk == -1: h_chk = (j + v) % 2 exp1 -= 1 else: if h_chk != (j + v) % 2: exp1 = -1 if exp2 != -1: if j not in v_chk: v_chk[j] = (i + v) % 2 exp2 -=1 else: if v_chk[j] != (i + v) % 2: exp2 = -1 if exp1 == -1 and exp2 == -2: 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)