結果

問題 No.1141 田グリッド
ユーザー Coki628Coki628
提出日時 2020-11-27 02:16:40
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,375 bytes
コンパイル時間 581 ms
コンパイル使用メモリ 87,544 KB
実行使用メモリ 94,320 KB
最終ジャッジ日時 2023-10-01 03:50:35
合計ジャッジ時間 7,785 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,716 KB
testcase_01 AC 72 ms
71,628 KB
testcase_02 AC 74 ms
71,464 KB
testcase_03 AC 72 ms
71,808 KB
testcase_04 AC 73 ms
71,764 KB
testcase_05 AC 73 ms
71,772 KB
testcase_06 AC 72 ms
71,616 KB
testcase_07 AC 72 ms
71,816 KB
testcase_08 AC 89 ms
77,340 KB
testcase_09 AC 86 ms
77,064 KB
testcase_10 AC 91 ms
77,172 KB
testcase_11 AC 85 ms
77,120 KB
testcase_12 AC 92 ms
76,940 KB
testcase_13 AC 283 ms
94,320 KB
testcase_14 AC 344 ms
92,064 KB
testcase_15 AC 290 ms
80,720 KB
testcase_16 AC 288 ms
81,164 KB
testcase_17 AC 287 ms
80,496 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 284 ms
80,520 KB
testcase_22 AC 287 ms
80,352 KB
testcase_23 AC 285 ms
80,480 KB
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 #

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for k in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for k in range(c)] for k in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

def div(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD

H, W = MAP()
grid = list2d(H+2 ,W+2, 1)
for i in range(1, H+1):
    grid[i] = [1] + LIST() + [1]
    if grid[i].count(0):
        raise Exception

for i in range(H+2):
    for j in range(W+1):
        grid[i][j+1] *= grid[i][j]
        grid[i][j+1] %= MOD
for j in range(W+2):
    for i in range(H+1):
        grid[i+1][j] *= grid[i][j]
        grid[i+1][j] %= MOD

Q = INT()
for _ in range(Q):
    r, c = MAP()

    rd = div(grid[H+1][W+1] * grid[r][c], grid[H+1][c] * grid[r][W+1], MOD)
    ru = div(grid[r-1][W+1], grid[r-1][c], MOD)
    ld = div(grid[H+1][c-1], grid[r][c-1], MOD)
    lu = grid[r-1][c-1]
    res = rd * ru * ld * lu % MOD
    print(res)
0