結果

問題 No.1141 田グリッド
ユーザー McGregorshMcGregorsh
提出日時 2023-07-13 22:17:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,917 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 116,608 KB
最終ジャッジ日時 2024-09-15 08:08:05
合計ジャッジ時間 12,213 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
88,064 KB
testcase_01 AC 147 ms
88,320 KB
testcase_02 AC 147 ms
88,064 KB
testcase_03 AC 151 ms
88,448 KB
testcase_04 AC 151 ms
88,320 KB
testcase_05 AC 155 ms
88,448 KB
testcase_06 AC 148 ms
88,448 KB
testcase_07 AC 146 ms
88,064 KB
testcase_08 AC 171 ms
89,984 KB
testcase_09 AC 171 ms
89,472 KB
testcase_10 AC 172 ms
89,600 KB
testcase_11 AC 170 ms
89,728 KB
testcase_12 AC 179 ms
90,112 KB
testcase_13 AC 307 ms
102,016 KB
testcase_14 AC 478 ms
116,608 KB
testcase_15 AC 326 ms
92,160 KB
testcase_16 AC 331 ms
92,160 KB
testcase_17 AC 326 ms
92,416 KB
testcase_18 AC 336 ms
92,672 KB
testcase_19 AC 333 ms
92,416 KB
testcase_20 AC 334 ms
92,416 KB
testcase_21 AC 324 ms
92,032 KB
testcase_22 AC 325 ms
92,416 KB
testcase_23 AC 323 ms
92,288 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
from sys import stdin
from fractions import Fraction
import math
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement, permutations
from bisect import bisect, bisect_left, bisect_right
from functools import reduce, lru_cache
from decimal import Decimal, getcontext, ROUND_HALF_UP
def i_input(): return int(stdin.readline())
def i_map(): return map(int, stdin.readline().split())
def i_list(): return list(i_map())
def s_input(): return stdin.readline()[:-1]
def s_map(): return s_input().split()
def s_list(): return list(s_map())
def lcm(a, b): return a * b // gcd(a, b)
def get_distance(x1, y1, x2, y2):
	  d = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
	  return d
def rotate(table):
   	  n_fild = []
   	  for x in zip(*table[::-1]):
   	  	  n_fild.append(x)
   	  return n_fild
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
MOD = 10 ** 9 + 7
MOD2 = 998244353
alpa = 'abcdefghijklmnopqrstuvwxyz'
ALPA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'


def main():
   
   H, W = i_map()
   A = [i_list() for i in range(H)]
   
   total = 1
   for i in range(H):
   	  for j in range(W):
   	  	  total *= A[i][j]
   	  	  total %= MOD
   
   tate = deepcopy(A)
   for i in range(W):
   	  for j in range(H-1):
   	  	  tate[j+1][i] *= tate[j][i]
   	  	  tate[j+1][i] %= MOD
   
   yoko = deepcopy(A)
   for i in range(H):
   	  for j in range(W-1):
   	  	  yoko[i][j+1] *= yoko[i][j]
   	  	  yoko[i][j+1] %= MOD
   	  	  
   
   
   Q = int(input())
   for i in range(Q):
   	  r, c = i_map()
   	  r -= 1
   	  c -= 1
   	  score = tate[-1][c] * yoko[r][-1] * pow(A[r][c], MOD-2, MOD) % MOD
   	  invp = pow(score, MOD-2, MOD)
   	  print(total * invp % MOD)
   
if __name__ == '__main__':
    main()



0