結果

問題 No.1141 田グリッド
ユーザー brthyyjpbrthyyjp
提出日時 2021-03-20 14:18:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 729 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 82,280 KB
実行使用メモリ 94,932 KB
最終ジャッジ日時 2024-05-01 00:34:53
合計ジャッジ時間 13,877 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
51,968 KB
testcase_01 AC 34 ms
52,480 KB
testcase_02 AC 33 ms
52,344 KB
testcase_03 AC 33 ms
52,224 KB
testcase_04 AC 32 ms
52,224 KB
testcase_05 AC 33 ms
52,224 KB
testcase_06 AC 36 ms
52,224 KB
testcase_07 AC 33 ms
52,524 KB
testcase_08 AC 57 ms
69,888 KB
testcase_09 AC 50 ms
66,048 KB
testcase_10 AC 59 ms
69,760 KB
testcase_11 AC 57 ms
67,860 KB
testcase_12 AC 57 ms
69,632 KB
testcase_13 AC 517 ms
92,204 KB
testcase_14 AC 515 ms
94,932 KB
testcase_15 AC 508 ms
84,436 KB
testcase_16 AC 507 ms
84,760 KB
testcase_17 AC 521 ms
84,524 KB
testcase_18 AC 461 ms
83,648 KB
testcase_19 AC 470 ms
83,696 KB
testcase_20 AC 474 ms
83,060 KB
testcase_21 AC 501 ms
84,420 KB
testcase_22 AC 501 ms
84,112 KB
testcase_23 AC 503 ms
83,960 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
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

h, w = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]
mod = 1000000007

X = [[1]*(w+1) for i in range(h+1)]
for i in range(h):
    for j in range(w):
        X[i+1][j+1] = X[i+1][j]*X[i][j+1]*pow(X[i][j],mod-2,mod)*A[i][j]
        X[i+1][j+1] %= mod

def rect(r1, c1, r2, c2):
    res = X[r2][c2]*pow(X[r2][c1],mod-2, mod)*pow(X[r1][c2],mod-2, mod)*X[r1][c1]
    return res%mod

#print(X)
#print(X[h][w]%mod)

q = int(input())
for i in range(q):
    r, c = map(int, input().split())
    r, c = r-1, c-1
    ans = rect(r+1, c+1, h, w)*rect(0, c+1, r, w)*rect(r+1, 0, h, c)*rect(0, 0, r, c)
    print(ans%mod)
0