結果
問題 | No.1141 田グリッド |
ユーザー | McGregorsh |
提出日時 | 2023-07-13 22:17:04 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,917 bytes |
コンパイル時間 | 1,608 ms |
コンパイル使用メモリ | 86,072 KB |
実行使用メモリ | 119,336 KB |
最終ジャッジ日時 | 2023-10-13 11:06:53 |
合計ジャッジ時間 | 17,004 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 234 ms
89,868 KB |
testcase_01 | AC | 233 ms
89,772 KB |
testcase_02 | AC | 233 ms
89,980 KB |
testcase_03 | AC | 232 ms
89,684 KB |
testcase_04 | AC | 232 ms
89,668 KB |
testcase_05 | AC | 232 ms
89,736 KB |
testcase_06 | AC | 235 ms
89,732 KB |
testcase_07 | AC | 233 ms
89,716 KB |
testcase_08 | AC | 271 ms
92,628 KB |
testcase_09 | AC | 257 ms
92,596 KB |
testcase_10 | AC | 259 ms
92,376 KB |
testcase_11 | AC | 259 ms
92,204 KB |
testcase_12 | AC | 267 ms
92,552 KB |
testcase_13 | AC | 399 ms
103,644 KB |
testcase_14 | AC | 581 ms
119,336 KB |
testcase_15 | AC | 411 ms
95,844 KB |
testcase_16 | AC | 412 ms
96,116 KB |
testcase_17 | AC | 419 ms
95,932 KB |
testcase_18 | AC | 413 ms
96,520 KB |
testcase_19 | AC | 416 ms
96,272 KB |
testcase_20 | AC | 421 ms
96,524 KB |
testcase_21 | AC | 409 ms
95,756 KB |
testcase_22 | AC | 408 ms
95,544 KB |
testcase_23 | AC | 405 ms
95,776 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] * pow(A[r][c], MOD-2, MOD) % MOD invp = pow(score, MOD-2, MOD) print(total * invp % MOD) if __name__ == '__main__': main()