結果
問題 | No.226 0-1パズル |
ユーザー | ayaoni |
提出日時 | 2021-04-28 17:32:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 54 ms / 5,000 ms |
コード長 | 2,266 bytes |
コンパイル時間 | 610 ms |
コンパイル使用メモリ | 82,320 KB |
実行使用メモリ | 61,952 KB |
最終ジャッジ日時 | 2024-07-26 14:27:21 |
合計ジャッジ時間 | 2,013 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
52,736 KB |
testcase_01 | AC | 43 ms
52,608 KB |
testcase_02 | AC | 44 ms
52,608 KB |
testcase_03 | AC | 40 ms
52,736 KB |
testcase_04 | AC | 51 ms
60,288 KB |
testcase_05 | AC | 43 ms
52,096 KB |
testcase_06 | AC | 40 ms
52,480 KB |
testcase_07 | AC | 42 ms
52,736 KB |
testcase_08 | AC | 43 ms
52,608 KB |
testcase_09 | AC | 39 ms
52,096 KB |
testcase_10 | AC | 42 ms
52,480 KB |
testcase_11 | AC | 39 ms
52,480 KB |
testcase_12 | AC | 41 ms
52,224 KB |
testcase_13 | AC | 40 ms
52,096 KB |
testcase_14 | AC | 40 ms
52,352 KB |
testcase_15 | AC | 42 ms
52,224 KB |
testcase_16 | AC | 40 ms
52,736 KB |
testcase_17 | AC | 52 ms
61,568 KB |
testcase_18 | AC | 51 ms
61,184 KB |
testcase_19 | AC | 50 ms
61,568 KB |
testcase_20 | AC | 51 ms
61,568 KB |
testcase_21 | AC | 54 ms
61,952 KB |
ソースコード
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) H,W = MI() X = [S() for _ in range(H)] mod = 10**9+7 ans1 = 1 # 1列目が縞々 for j in range(W): zero,one,q = 0,0,0 for i in range(H): x = X[i][j] if x == '?': q += 1 else: x = int(x) if i % 2 == 0: if x == 0: zero += 1 else: one += 1 else: if x == 0: one += 1 else: zero += 1 a = 1 if zero and one: a = 0 elif zero == 0 and one == 0: a = 2 ans1 *= a ans1 %= mod ans2 = 1 # 1行目が縞々 for i in range(H): zero,one,q = 0,0,0 for j in range(W): x = X[i][j] if x == '?': q += 1 else: x = int(x) if j % 2 == 0: if x == 0: zero += 1 else: one += 1 else: if x == 0: one += 1 else: zero += 1 a = 1 if zero and one: a = 0 elif zero == 0 and one == 0: a = 2 ans2 *= a ans2 %= mod ans3 = 0 # 1行目,1列目が縞々 X1 = [] X2 = [] A = '01'*(W//2)+'0'*(W % 2) for i in range(H): X1.append(A) if A[-1] == '0': A += '1' else: A += '0' A = A[1:] X2.append(A) for i in range(H): for j in range(W): if X[i][j] != '?' and X1[i][j] != X[i][j]: break else: continue break else: ans3 += 1 for i in range(H): for j in range(W): if X[i][j] != '?' and X2[i][j] != X[i][j]: break else: continue break else: ans3 += 1 ans = ans1+ans2-ans3 ans %= mod print(ans)