結果

問題 No.1141 田グリッド
ユーザー AEnAEn
提出日時 2022-05-21 17:00:07
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 755 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 81,804 KB
実行使用メモリ 88,852 KB
最終ジャッジ日時 2023-10-20 16:24:41
合計ジャッジ時間 5,684 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,556 KB
testcase_01 AC 35 ms
53,556 KB
testcase_02 AC 35 ms
53,556 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 60 ms
66,616 KB
testcase_09 AC 53 ms
64,488 KB
testcase_10 AC 59 ms
66,616 KB
testcase_11 AC 53 ms
64,488 KB
testcase_12 AC 65 ms
68,624 KB
testcase_13 RE -
testcase_14 AC 367 ms
82,668 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
A = [list(map(int, input().split())) for  _ in range(H)]
H_n = [1]*H
W_n = [1]*W
H_z = [0]*H
W_z = [0]*W
mod = 10**9+7
al = 1
al_z = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == 0:
            H_z[i] += 1
            W_z[j] += 1
            al_z += 1
        else:
            H_n[i] *= A[i][j]
            W_n[j] *= A[i][j]
            al *= A[i][j]
            H_n[i] %= mod
            W_n[j] %= mod
            al %= mod

Q = int(input())
for i in range(Q):
    r, c = map(int, input().split())
    if H_z[r-1]+W_z[c-1]-(A[i][j]==0) != al_z:
        print(0)
    else:
        p = 1 if A[r-1][c-1] == 0 else A[r-1][c-1]
        print((al*pow(H_n[r-1], mod-2, mod)*pow(W_n[c-1], mod-2, mod)*p)%mod)
0