結果
問題 | No.1141 田グリッド |
ユーザー | McGregorsh |
提出日時 | 2023-07-13 22:26:08 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,923 bytes |
コンパイル時間 | 281 ms |
コンパイル使用メモリ | 82,092 KB |
実行使用メモリ | 116,656 KB |
最終ジャッジ日時 | 2024-09-15 08:16:19 |
合計ジャッジ時間 | 11,612 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 145 ms
88,392 KB |
testcase_01 | AC | 143 ms
88,460 KB |
testcase_02 | AC | 142 ms
88,308 KB |
testcase_03 | AC | 142 ms
88,320 KB |
testcase_04 | AC | 142 ms
88,424 KB |
testcase_05 | AC | 142 ms
88,304 KB |
testcase_06 | AC | 140 ms
88,596 KB |
testcase_07 | AC | 142 ms
88,284 KB |
testcase_08 | AC | 173 ms
89,628 KB |
testcase_09 | AC | 167 ms
89,332 KB |
testcase_10 | AC | 171 ms
89,460 KB |
testcase_11 | AC | 166 ms
90,000 KB |
testcase_12 | AC | 172 ms
89,596 KB |
testcase_13 | AC | 309 ms
101,748 KB |
testcase_14 | AC | 473 ms
116,656 KB |
testcase_15 | AC | 312 ms
92,168 KB |
testcase_16 | AC | 318 ms
91,880 KB |
testcase_17 | AC | 325 ms
92,200 KB |
testcase_18 | AC | 316 ms
92,588 KB |
testcase_19 | AC | 319 ms
92,204 KB |
testcase_20 | AC | 312 ms
92,612 KB |
testcase_21 | AC | 318 ms
92,216 KB |
testcase_22 | AC | 317 ms
92,084 KB |
testcase_23 | AC | 320 ms
91,948 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 | - |
ソースコード
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] % MOD * pow(A[r][c], MOD-2, MOD) % MOD invp = pow(score, MOD-2, MOD) print(total * invp % MOD) if __name__ == '__main__': main()