結果

問題 No.226 0-1パズル
ユーザー asumo0729asumo0729
提出日時 2022-07-16 11:11:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 1,243 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 77,752 KB
最終ジャッジ日時 2023-10-04 12:08:57
合計ジャッジ時間 3,902 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
72,980 KB
testcase_01 AC 112 ms
72,484 KB
testcase_02 AC 109 ms
72,860 KB
testcase_03 AC 109 ms
72,668 KB
testcase_04 AC 132 ms
77,664 KB
testcase_05 AC 109 ms
72,672 KB
testcase_06 AC 108 ms
72,820 KB
testcase_07 AC 109 ms
72,820 KB
testcase_08 AC 107 ms
72,996 KB
testcase_09 AC 108 ms
73,028 KB
testcase_10 AC 109 ms
72,612 KB
testcase_11 AC 109 ms
72,672 KB
testcase_12 AC 109 ms
72,604 KB
testcase_13 AC 109 ms
72,668 KB
testcase_14 AC 109 ms
72,772 KB
testcase_15 AC 111 ms
72,672 KB
testcase_16 AC 108 ms
72,472 KB
testcase_17 AC 131 ms
77,720 KB
testcase_18 AC 131 ms
77,752 KB
testcase_19 AC 132 ms
77,664 KB
testcase_20 AC 131 ms
77,604 KB
testcase_21 AC 132 ms
77,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from operator import itemgetter
from collections import defaultdict, deque
import heapq
from heapq import heapify, heappop, _heapify_max, heappush
from bisect import bisect_left, bisect_right
import math
import itertools
import copy

stdin=sys.stdin
#sys.setrecursionlimit(10 ** 7)
## import pypyjit
## pypyjit.set_param('max_unroll_recursion=-1')

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()
Yp=lambda:print('Yes')
Np=lambda:print('No')
inf = 1 << 60
inf = float('inf')
mod = 10 ** 9 + 7
#mod = 998244353
eps = 1e-9
sortkey1 = itemgetter(0)
sortkey2 = lambda x: (x[0], x[1])



###############################################################

def f(s):
    cnt = 1
    for si in s:
        c = all(x != '1' for x in si[::2]) & all(x != '0' for x in si[1::2])
        c += all(x != '0' for x in si[::2]) & all(x != '1' for x in si[1::2])
        cnt *= c % mod
    return cnt

H, W = lp()
S = [sp() for _ in range(H)]
ans = f(S) + f(zip(*S))
ans %= mod
r = '01'
c1 = c2 = 1
for h in range(H):
    for w in range(W):
        if S[h][w] == r[(h + w) % 2]: c1 = 0
        if S[h][w] == r[(h + w + 1) % 2]: c2 = 0
ans -= c1 + c2
ans %= mod
print(ans)
0