結果
| 問題 |
No.1141 田グリッド
|
| コンテスト | |
| ユーザー |
tktk_snsn
|
| 提出日時 | 2020-12-23 21:17:21 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 681 bytes |
| コンパイル時間 | 200 ms |
| コンパイル使用メモリ | 82,220 KB |
| 実行使用メモリ | 89,780 KB |
| 最終ジャッジ日時 | 2024-09-21 16:32:23 |
| 合計ジャッジ時間 | 6,090 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 10 |
ソースコード
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)
tktk_snsn