結果
問題 | No.226 0-1パズル |
ユーザー |
![]() |
提出日時 | 2022-07-16 11:11:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 65 ms / 5,000 ms |
コード長 | 1,243 bytes |
コンパイル時間 | 162 ms |
コンパイル使用メモリ | 82,444 KB |
実行使用メモリ | 74,264 KB |
最終ジャッジ日時 | 2024-07-26 14:28:44 |
合計ジャッジ時間 | 2,186 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
import sysfrom operator import itemgetterfrom collections import defaultdict, dequeimport heapqfrom heapq import heapify, heappop, _heapify_max, heappushfrom bisect import bisect_left, bisect_rightimport mathimport itertoolsimport copystdin=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 << 60inf = float('inf')mod = 10 ** 9 + 7#mod = 998244353eps = 1e-9sortkey1 = itemgetter(0)sortkey2 = lambda x: (x[0], x[1])###############################################################def f(s):cnt = 1for 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 % modreturn cntH, W = lp()S = [sp() for _ in range(H)]ans = f(S) + f(zip(*S))ans %= modr = '01'c1 = c2 = 1for h in range(H):for w in range(W):if S[h][w] == r[(h + w) % 2]: c1 = 0if S[h][w] == r[(h + w + 1) % 2]: c2 = 0ans -= c1 + c2ans %= modprint(ans)