結果

問題 No.1141 田グリッド
ユーザー roarisroaris
提出日時 2020-08-09 22:21:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 672 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 82,132 KB
実行使用メモリ 87,432 KB
最終ジャッジ日時 2024-04-15 17:20:36
合計ジャッジ時間 7,555 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,472 KB
testcase_01 AC 45 ms
52,312 KB
testcase_02 AC 39 ms
52,532 KB
testcase_03 AC 39 ms
52,608 KB
testcase_04 AC 40 ms
52,468 KB
testcase_05 AC 39 ms
53,076 KB
testcase_06 AC 41 ms
53,220 KB
testcase_07 AC 39 ms
52,708 KB
testcase_08 AC 56 ms
65,620 KB
testcase_09 AC 53 ms
64,160 KB
testcase_10 AC 56 ms
66,296 KB
testcase_11 AC 55 ms
64,920 KB
testcase_12 AC 59 ms
66,984 KB
testcase_13 AC 208 ms
87,432 KB
testcase_14 AC 248 ms
84,368 KB
testcase_15 AC 199 ms
77,288 KB
testcase_16 AC 197 ms
77,320 KB
testcase_17 AC 201 ms
77,380 KB
testcase_18 AC 192 ms
78,000 KB
testcase_19 AC 194 ms
77,484 KB
testcase_20 AC 191 ms
77,416 KB
testcase_21 AC 199 ms
77,396 KB
testcase_22 AC 199 ms
77,392 KB
testcase_23 AC 199 ms
77,348 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
input = sys.stdin.readline

def inv(x):
    return pow(x, MOD-2, MOD)

H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
MOD = 10**9+7
ans = 1

for i in range(H):
    for j in range(W):
        ans *= A[i][j]
        ans %= MOD

h, w = [], []

for i in range(H):
    res = 1
    
    for j in range(W):
        res *= A[i][j]
        res %= MOD
    
    h.append(res)

for i in range(W):
    res = 1
    
    for j in range(H):
        res *= A[j][i]
        res %= MOD
    
    w.append(res)

Q = int(input())

for _ in range(Q):
    r, c = map(int, input().split())
    print(ans*inv(h[r-1])*inv(w[c-1])*A[r-1][c-1]%MOD)
0