結果

問題 No.1141 田グリッド
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-23 21:17:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 681 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 81,472 KB
実行使用メモリ 89,252 KB
最終ジャッジ日時 2023-10-21 15:18:31
合計ジャッジ時間 6,284 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,264 KB
testcase_01 AC 36 ms
53,264 KB
testcase_02 AC 36 ms
53,264 KB
testcase_03 AC 35 ms
53,264 KB
testcase_04 AC 35 ms
53,264 KB
testcase_05 AC 35 ms
53,264 KB
testcase_06 AC 35 ms
53,264 KB
testcase_07 AC 36 ms
53,264 KB
testcase_08 AC 47 ms
64,008 KB
testcase_09 AC 47 ms
61,960 KB
testcase_10 AC 48 ms
61,956 KB
testcase_11 AC 47 ms
61,956 KB
testcase_12 AC 52 ms
64,096 KB
testcase_13 AC 149 ms
89,252 KB
testcase_14 AC 170 ms
81,968 KB
testcase_15 AC 107 ms
77,932 KB
testcase_16 AC 112 ms
77,916 KB
testcase_17 AC 114 ms
77,948 KB
testcase_18 AC 103 ms
77,868 KB
testcase_19 AC 103 ms
77,872 KB
testcase_20 AC 103 ms
77,880 KB
testcase_21 AC 113 ms
77,916 KB
testcase_22 AC 112 ms
77,916 KB
testcase_23 AC 104 ms
77,908 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.buffer.readline
sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7

H, W = map(int, input().split())
A = tuple(tuple(map(int, input().split())) for _ in range(H))

ALL = 1
row = [1] * H
col = [1] * W
for i, ai in enumerate(A):
    for j, a in enumerate(ai):
        row[i] *= a
        col[j] *= a
        ALL *= a
        row[i] %= mod
        col[j] %= mod
        ALL %= mod

for i in range(H):
    row[i] = pow(row[i], mod - 2, mod)
for j in range(W):
    col[j] = pow(col[j], mod - 2, mod)


Q = int(input())
for _ in range(Q):
    r, c = map(int, input().split())
    r -= 1
    c -= 1
    res = ALL * row[r] * col[c] * A[r][c] % mod
    print(res)
0