結果

問題 No.1141 田グリッド
ユーザー mkawa2mkawa2
提出日時 2021-06-17 15:33:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,284 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 32,248 KB
最終ジャッジ日時 2023-08-30 22:58:56
合計ジャッジ時間 7,189 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,036 KB
testcase_01 AC 16 ms
7,992 KB
testcase_02 AC 18 ms
8,140 KB
testcase_03 AC 18 ms
8,024 KB
testcase_04 AC 17 ms
8,180 KB
testcase_05 AC 20 ms
8,060 KB
testcase_06 AC 16 ms
8,096 KB
testcase_07 AC 16 ms
8,076 KB
testcase_08 AC 23 ms
8,588 KB
testcase_09 AC 20 ms
8,068 KB
testcase_10 AC 22 ms
8,580 KB
testcase_11 AC 21 ms
8,564 KB
testcase_12 AC 23 ms
8,532 KB
testcase_13 AC 413 ms
23,140 KB
testcase_14 AC 488 ms
32,248 KB
testcase_15 AC 220 ms
19,912 KB
testcase_16 AC 222 ms
20,000 KB
testcase_17 AC 223 ms
20,144 KB
testcase_18 AC 194 ms
20,428 KB
testcase_19 AC 194 ms
20,108 KB
testcase_20 AC 192 ms
20,164 KB
testcase_21 AC 220 ms
19,724 KB
testcase_22 AC 221 ms
19,556 KB
testcase_23 AC 218 ms
19,608 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

def tos(row):
    res = 1
    cnt = 0
    for a in row:
        res = res*a%md
        if a == 0: cnt += 1
    return res, cnt

h, w = LI()
aa = LLI(h)
q = II()
ij = LLI1(q)
zi = []
zj = []
si = []
sj = []
s = 1
z = 0
for row in aa:
    cur, cnt = tos(row)
    zi.append(cnt)
    z += cnt
    s = s*cur%md
    si.append(pow(cur, md-2, md))
for col in zip(*aa):
    cur, cnt = tos(col)
    zj.append(cnt)
    sj.append(pow(cur, md-2, md))

for i, j in ij:
    if zi[i]+zj[j]-(aa[i][j] == 0) == z:
        ans = s*si[i]*sj[j]*aa[i][j]%md
    else:
        ans = 0
    print(ans)
0