結果

問題 No.1141 田グリッド
ユーザー mkawa2mkawa2
提出日時 2021-06-17 15:16:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,356 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 10,960 KB
実行使用メモリ 23,624 KB
最終ジャッジ日時 2023-08-30 22:43:07
合計ジャッジ時間 6,490 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,024 KB
testcase_01 AC 16 ms
8,068 KB
testcase_02 AC 18 ms
8,064 KB
testcase_03 AC 17 ms
8,016 KB
testcase_04 AC 17 ms
8,028 KB
testcase_05 AC 16 ms
8,148 KB
testcase_06 AC 16 ms
8,116 KB
testcase_07 AC 16 ms
8,016 KB
testcase_08 AC 23 ms
8,496 KB
testcase_09 AC 20 ms
8,120 KB
testcase_10 AC 24 ms
8,500 KB
testcase_11 AC 23 ms
8,596 KB
testcase_12 AC 24 ms
8,472 KB
testcase_13 AC 386 ms
15,412 KB
testcase_14 AC 472 ms
23,624 KB
testcase_15 AC 206 ms
12,312 KB
testcase_16 AC 213 ms
12,428 KB
testcase_17 AC 212 ms
12,196 KB
testcase_18 AC 107 ms
12,796 KB
testcase_19 AC 106 ms
12,596 KB
testcase_20 AC 108 ms
12,500 KB
testcase_21 AC 204 ms
12,592 KB
testcase_22 AC 200 ms
12,180 KB
testcase_23 AC 203 ms
12,432 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
    for a in row:
        res = res*a%md
    return res

h, w = LI()
aa = LLI(h)
zi, zj = set(), set()
for i in range(h):
    for j in range(w):
        if aa[i][j] == 0:
            zi.add(i)
            zj.add(j)

si = []
sj = []
s = 1
for row in aa:
    cur = tos(row)
    s = s*cur%md
    si.append(pow(cur, md-2, md))
for col in zip(*aa):
    sj.append(pow(tos(col), md-2, md))
q = II()
if len(zi) > 1 or len(zj) > 1:
    for _ in range(q): print(0)
    exit()
for _ in range(q):
    i, j = LI1()
    ans = s*si[i]*sj[j]*aa[i][j]%md
    if zi and i not in zi: ans = 0
    if zj and j not in zj: ans = 0
    print(ans)
0