結果
問題 | No.1141 田グリッド |
ユーザー | buey_t |
提出日時 | 2023-03-28 11:27:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 494 ms / 2,000 ms |
コード長 | 2,911 bytes |
コンパイル時間 | 172 ms |
コンパイル使用メモリ | 82,280 KB |
実行使用メモリ | 116,532 KB |
最終ジャッジ日時 | 2024-09-20 02:15:21 |
合計ジャッジ時間 | 11,768 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 135 ms
89,368 KB |
testcase_01 | AC | 137 ms
89,296 KB |
testcase_02 | AC | 143 ms
89,332 KB |
testcase_03 | AC | 143 ms
89,192 KB |
testcase_04 | AC | 142 ms
89,332 KB |
testcase_05 | AC | 144 ms
89,208 KB |
testcase_06 | AC | 138 ms
89,216 KB |
testcase_07 | AC | 143 ms
89,288 KB |
testcase_08 | AC | 198 ms
91,008 KB |
testcase_09 | AC | 182 ms
90,788 KB |
testcase_10 | AC | 193 ms
90,708 KB |
testcase_11 | AC | 196 ms
91,340 KB |
testcase_12 | AC | 201 ms
91,172 KB |
testcase_13 | AC | 365 ms
107,008 KB |
testcase_14 | AC | 494 ms
116,532 KB |
testcase_15 | AC | 370 ms
95,044 KB |
testcase_16 | AC | 372 ms
94,792 KB |
testcase_17 | AC | 367 ms
95,392 KB |
testcase_18 | AC | 362 ms
94,776 KB |
testcase_19 | AC | 360 ms
95,060 KB |
testcase_20 | AC | 361 ms
94,660 KB |
testcase_21 | AC | 372 ms
95,096 KB |
testcase_22 | AC | 380 ms
95,096 KB |
testcase_23 | AC | 373 ms
94,964 KB |
testcase_24 | AC | 370 ms
94,948 KB |
testcase_25 | AC | 347 ms
95,040 KB |
testcase_26 | AC | 375 ms
95,428 KB |
testcase_27 | AC | 378 ms
95,240 KB |
testcase_28 | AC | 354 ms
94,912 KB |
testcase_29 | AC | 375 ms
95,464 KB |
testcase_30 | AC | 374 ms
95,388 KB |
testcase_31 | AC | 375 ms
95,028 KB |
testcase_32 | AC | 372 ms
95,092 KB |
testcase_33 | AC | 362 ms
94,964 KB |
ソースコード
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!!!!!!!!!!!!!!!!!!!!!!!!!! ''' または、か 0が含まれてるパターンがえぐい 二次元を1次元に変えてしまえばセグメントツリーが使えるのかな だから田なのか ''' H,W = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(H)] acm1 = [[1]*(W+1) for _ in range(H+1)] acm2 = [[1]*(W+1) for _ in range(H+1)] acm3 = [[1]*(W+1) for _ in range(H+1)] acm4 = [[1]*(W+1) for _ in range(H+1)] for i in range(H): for j in range(W): acm1[i][j] = A[i][j] acm2[i][j] = A[i][j] acm3[i][j] = A[i][j] acm4[i][j] = A[i][j] for i in range(H): for j in range(W-1): acm1[i][j+1] *= acm1[i][j] acm1[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 for i in reversed(range(H)): for j in range(W-1): acm3[i][j+1] *= acm3[i][j] acm3[i][j+1] %= mod1 for j in range(W): for i in reversed(range(1,H)): acm3[i-1][j] *= acm3[i][j] acm3[i-1][j] %= mod1 for i in range(H): for j in reversed(range(1,W)): acm2[i][j-1] *= acm2[i][j] acm2[i][j-1] %= mod1 for j in reversed(range(W)): for i in range(H-1): acm2[i+1][j] *= acm2[i][j] acm2[i+1][j] %= mod1 for i in reversed(range(H)): for j in reversed(range(1,W)): acm4[i][j-1] *= acm4[i][j] acm4[i][j-1] %= mod1 for j in reversed(range(W)): for i in reversed(range(1,H)): acm4[i-1][j] *= acm4[i][j] acm4[i-1][j] %= mod1 Q = int(input()) for _ in range(Q): r,c = map(int, input().split()) print(acm1[r-2][c-2]%mod1*acm2[r-2][c]%mod1*acm3[r][c-2]%mod1*acm4[r][c]%mod1) if __name__ == '__main__': main()