結果

問題 No.1141 田グリッド
ユーザー TsubajiroTsubajiro
提出日時 2022-05-24 00:11:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 730 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 11,880 KB
実行使用メモリ 30,700 KB
最終ジャッジ日時 2023-10-20 17:50:11
合計ジャッジ時間 7,651 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,204 KB
testcase_01 AC 28 ms
10,204 KB
testcase_02 AC 29 ms
10,204 KB
testcase_03 WA -
testcase_04 AC 30 ms
10,204 KB
testcase_05 WA -
testcase_06 AC 30 ms
10,204 KB
testcase_07 AC 28 ms
10,204 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 RE -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

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