結果

問題 No.1141 田グリッド
ユーザー buey_tbuey_t
提出日時 2023-03-28 10:07:27
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,969 bytes
コンパイル時間 1,097 ms
コンパイル使用メモリ 81,688 KB
実行使用メモリ 265,264 KB
最終ジャッジ日時 2023-10-20 05:38:51
合計ジャッジ時間 7,656 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
84,208 KB
testcase_01 AC 123 ms
84,208 KB
testcase_02 AC 124 ms
84,212 KB
testcase_03 AC 125 ms
84,212 KB
testcase_04 AC 128 ms
84,208 KB
testcase_05 AC 124 ms
84,208 KB
testcase_06 AC 124 ms
84,208 KB
testcase_07 AC 124 ms
84,208 KB
testcase_08 AC 192 ms
89,360 KB
testcase_09 AC 170 ms
89,368 KB
testcase_10 AC 196 ms
89,384 KB
testcase_11 AC 218 ms
89,544 KB
testcase_12 AC 195 ms
89,392 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    from copy import deepcopy
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    #再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    
    '''
    または、か
    
    
    '''
    
    H,W = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    
    acm1 = [[1]*(W) for _ in range(H)]
    acm2 = [[1]*(W) for _ in range(H)]
    
    sm = 1
    for i in range(H):
        for j in range(W):
            sm *= A[i][j]
            acm1[i][j] = A[i][j]
            acm2[i][j] = A[i][j]
    
    for i in range(H):
        for j in range(W-1):
            acm2[i][j+1] *= acm2[i][j]
            acm2[i][j+1] %= mod1
    
    for j in range(W):
        for i in range(H-1):
            acm1[i+1][j] *= acm1[i][j]
            acm1[i+1][j] %= mod1
    
    gyou = [0]*(H)
    for i in range(H):
        gyou[i] = pow(acm2[i][W-1],mod1-2,mod1)
    retu = [0]*W
    for i in range(W):
        retu[i] = pow(acm1[H-1][i],mod1-2,mod1)
    
    Q = int(input())
    for _ in range(Q):
        r,c = map(int, input().split())
        
        print(sm*gyou[r-1]%mod1*retu[c-1]%mod1*A[r-1][c-1]%mod1)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0