結果

問題 No.1141 田グリッド
ユーザー mkawa2mkawa2
提出日時 2021-06-17 18:17:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,290 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 10,808 KB
実行使用メモリ 32,184 KB
最終ジャッジ日時 2023-09-01 02:56:10
合計ジャッジ時間 9,973 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,068 KB
testcase_01 AC 18 ms
8,124 KB
testcase_02 AC 17 ms
8,120 KB
testcase_03 AC 16 ms
8,068 KB
testcase_04 AC 16 ms
8,204 KB
testcase_05 AC 16 ms
8,040 KB
testcase_06 AC 16 ms
8,136 KB
testcase_07 AC 16 ms
8,212 KB
testcase_08 AC 22 ms
8,620 KB
testcase_09 AC 19 ms
8,120 KB
testcase_10 AC 24 ms
8,512 KB
testcase_11 AC 21 ms
8,544 KB
testcase_12 AC 23 ms
8,560 KB
testcase_13 AC 435 ms
23,232 KB
testcase_14 AC 509 ms
32,184 KB
testcase_15 AC 220 ms
19,892 KB
testcase_16 AC 238 ms
19,904 KB
testcase_17 AC 235 ms
20,188 KB
testcase_18 AC 202 ms
20,440 KB
testcase_19 AC 205 ms
20,188 KB
testcase_20 AC 205 ms
20,364 KB
testcase_21 AC 229 ms
19,652 KB
testcase_22 AC 225 ms
19,772 KB
testcase_23 AC 228 ms
19,620 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 205 ms
20,536 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 203 ms
20,000 KB
testcase_33 AC 203 ms
19,872 KB
権限があれば一括ダウンロードができます

ソースコード

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:
        if a == 0: cnt += 1
        else: res = res*a%md
    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