結果
問題 | No.1141 田グリッド |
ユーザー | McGregorsh |
提出日時 | 2023-07-13 22:26:08 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,923 bytes |
コンパイル時間 | 382 ms |
コンパイル使用メモリ | 86,844 KB |
実行使用メモリ | 119,692 KB |
最終ジャッジ日時 | 2023-10-13 11:16:10 |
合計ジャッジ時間 | 14,918 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 239 ms
89,960 KB |
testcase_01 | AC | 241 ms
89,880 KB |
testcase_02 | AC | 236 ms
90,096 KB |
testcase_03 | AC | 241 ms
90,056 KB |
testcase_04 | AC | 243 ms
90,128 KB |
testcase_05 | AC | 237 ms
90,084 KB |
testcase_06 | AC | 240 ms
90,000 KB |
testcase_07 | AC | 239 ms
89,940 KB |
testcase_08 | AC | 274 ms
92,348 KB |
testcase_09 | AC | 266 ms
92,380 KB |
testcase_10 | AC | 268 ms
92,768 KB |
testcase_11 | AC | 266 ms
92,360 KB |
testcase_12 | AC | 277 ms
92,596 KB |
testcase_13 | AC | 408 ms
103,204 KB |
testcase_14 | AC | 581 ms
119,692 KB |
testcase_15 | AC | 414 ms
96,164 KB |
testcase_16 | AC | 417 ms
96,464 KB |
testcase_17 | AC | 417 ms
96,008 KB |
testcase_18 | AC | 414 ms
96,324 KB |
testcase_19 | AC | 410 ms
96,448 KB |
testcase_20 | AC | 416 ms
96,664 KB |
testcase_21 | AC | 410 ms
95,728 KB |
testcase_22 | AC | 414 ms
95,664 KB |
testcase_23 | AC | 412 ms
96,028 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()