結果

問題 No.1141 田グリッド
ユーザー AEnAEn
提出日時 2022-05-21 16:42:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 562 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 88,704 KB
最終ジャッジ日時 2024-09-20 11:55:04
合計ジャッジ時間 8,413 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,096 KB
testcase_01 AC 38 ms
51,840 KB
testcase_02 AC 38 ms
52,096 KB
testcase_03 AC 38 ms
51,968 KB
testcase_04 AC 37 ms
52,096 KB
testcase_05 AC 37 ms
52,224 KB
testcase_06 AC 39 ms
52,352 KB
testcase_07 AC 39 ms
52,224 KB
testcase_08 AC 67 ms
67,200 KB
testcase_09 AC 60 ms
64,640 KB
testcase_10 AC 69 ms
66,688 KB
testcase_11 AC 60 ms
64,768 KB
testcase_12 AC 75 ms
69,760 KB
testcase_13 AC 264 ms
88,704 KB
testcase_14 AC 318 ms
82,432 KB
testcase_15 AC 236 ms
78,464 KB
testcase_16 AC 225 ms
77,568 KB
testcase_17 AC 231 ms
78,464 KB
testcase_18 AC 215 ms
78,464 KB
testcase_19 AC 215 ms
77,568 KB
testcase_20 AC 211 ms
77,568 KB
testcase_21 AC 225 ms
78,208 KB
testcase_22 AC 227 ms
78,208 KB
testcase_23 AC 228 ms
78,208 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 #

H, W = map(int, input().split())
A = [list(map(int, input().split())) for  _ in range(H)]
H_inv = [0]*H
W_inv = [0]*W
mod = 10**9+7
al = 1
for i in range(H):
    sm = 1
    for j in range(W):
        al *= A[i][j]
        sm *= A[i][j]
        al %= mod
        sm %= mod
    H_inv[i] = pow(sm, mod-2, mod)
for j in range(W):
    sm = 1
    for i in range(H):
        sm *= A[i][j]
        sm %= mod
    W_inv[j] = pow(sm, mod-2, mod)

Q = int(input())
for i in range(Q):
    r, c = map(int, input().split())
    print((al*H_inv[r-1]*W_inv[c-1]*A[r-1][c-1])%mod)
0