結果

問題 No.1141 田グリッド
ユーザー sepa38
提出日時 2023-03-28 10:31:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 445 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 82,492 KB
実行使用メモリ 88,688 KB
最終ジャッジ日時 2024-09-20 01:36:46
合計ジャッジ時間 8,129 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
b = [1] * h
v = [1] * w
mod = 10 ** 9 + 7
s = 1
for i in range(h):
  for j in range(w):
    s *= a[i][j]
    s %= mod
    b[i] *= a[i][j]
    b[i] %= mod
    v[j] *= a[i][j]
    v[j] %= mod
for _ in range(int(input())):
  r, c = map(lambda x: int(x)-1, input().split())
  ans = s * pow(b[r], mod-2, mod) * pow(v[c], mod-2, mod) * a[r][c] % mod
  print(ans)
0