結果

問題 No.1141 田グリッド
ユーザー c-yan
提出日時 2020-07-31 22:44:26
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 547 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 25,600 KB
最終ジャッジ日時 2024-07-06 20:04:11
合計ジャッジ時間 7,867 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 18 RE * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())

m = 1000000007

total = 1
rows = [1] * H
cols = [1] * W
for i in range(H):
    for j in range(W):
        x = A[i][j]
        total *= x
        total %= m
        rows[i] *= x
        rows[i] %= m
        cols[j] *= x
        cols[j] %= m

result = []
for _ in range(Q):
    r, c = map(int, input().split())
    result.append(total * pow(rows[r - 1], -1, m) % m * pow(cols[c - 1], -1, m) % m * A[r - 1][c - 1] % m)
print(result, sep='\n')
0