結果

問題 No.1141 田グリッド
ユーザー Tsubajiro
提出日時 2022-05-24 00:11:12
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 730 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 31,232 KB
最終ジャッジ日時 2024-09-20 13:27:48
合計ジャッジ時間 9,750 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 14 RE * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

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


AA = [[1]*(H+2)]

A[0][0]%=mod
for i in range(H):
    a=[1]
    for j in range(W):
        temp = a[-1]*A[i][j]
        temp%=mod
        a.append(temp)
    a.append(1)
    AA.append(a)

for j in range(W+1):
    for i in range(1,H+1):
        AA[i][j]*=AA[i-1][j]
        AA[i][j]%=mod
AA.append([1]*(H+2))
#print(AA)

Q = int(input())
for _ in range(Q):
    r,c=list(map(int, input().split()))
    #左上
    LU = AA[r-1][c-1]
    #右上
    RU = AA[r-1][W]//AA[r-1][c]
    #左下
    LB = AA[H][c-1]//AA[r][c-1]
    #右下
    RB = AA[H][W]*AA[r][c]//AA[r][W]//AA[H][c]
    print(LU*RU*LB*RB%mod)

0