結果
問題 | No.1141 田グリッド |
ユーザー | aaaaaaaaaa2230 |
提出日時 | 2022-03-07 23:40:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 265 ms / 2,000 ms |
コード長 | 1,612 bytes |
コンパイル時間 | 313 ms |
コンパイル使用メモリ | 82,676 KB |
実行使用メモリ | 109,568 KB |
最終ジャッジ日時 | 2024-07-22 20:46:22 |
合計ジャッジ時間 | 8,152 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
52,224 KB |
testcase_01 | AC | 35 ms
52,224 KB |
testcase_02 | AC | 37 ms
52,608 KB |
testcase_03 | AC | 35 ms
52,736 KB |
testcase_04 | AC | 42 ms
52,480 KB |
testcase_05 | AC | 36 ms
52,480 KB |
testcase_06 | AC | 36 ms
52,352 KB |
testcase_07 | AC | 36 ms
52,480 KB |
testcase_08 | AC | 96 ms
76,672 KB |
testcase_09 | AC | 86 ms
76,544 KB |
testcase_10 | AC | 98 ms
77,056 KB |
testcase_11 | AC | 90 ms
76,928 KB |
testcase_12 | AC | 98 ms
77,184 KB |
testcase_13 | AC | 173 ms
90,540 KB |
testcase_14 | AC | 265 ms
109,568 KB |
testcase_15 | AC | 198 ms
91,500 KB |
testcase_16 | AC | 209 ms
91,732 KB |
testcase_17 | AC | 216 ms
91,716 KB |
testcase_18 | AC | 192 ms
85,480 KB |
testcase_19 | AC | 183 ms
85,376 KB |
testcase_20 | AC | 189 ms
85,888 KB |
testcase_21 | AC | 194 ms
91,316 KB |
testcase_22 | AC | 214 ms
91,444 KB |
testcase_23 | AC | 197 ms
91,556 KB |
testcase_24 | AC | 195 ms
88,212 KB |
testcase_25 | AC | 187 ms
87,936 KB |
testcase_26 | AC | 204 ms
88,548 KB |
testcase_27 | AC | 195 ms
87,200 KB |
testcase_28 | AC | 181 ms
86,528 KB |
testcase_29 | AC | 178 ms
85,888 KB |
testcase_30 | AC | 199 ms
86,080 KB |
testcase_31 | AC | 174 ms
86,588 KB |
testcase_32 | AC | 184 ms
86,500 KB |
testcase_33 | AC | 189 ms
86,260 KB |
ソースコード
h,w = map(int,input().split()) A = [list(map(int,input().split())) for i in range(h)] mod = 10**9+7 q = int(input()) Q = [list(map(int,input().split())) for i in range(q)] ans = [1]*q accum = [[1]*(w+2) for i in range(h+2)] for i in range(h): for j in range(w): accum[i+1][j+1] = accum[i+1][j]*A[i][j] accum[i+1][j+1] %= mod for i in range(h): for j in range(w): accum[i+1][j+1] *= accum[i][j+1] accum[i+1][j+1] %= mod for i,(r,c) in enumerate(Q): ans[i] *= accum[r-1][c-1] accum = [[1]*(w+2) for i in range(h+2)] for i in range(h)[::-1]: for j in range(w)[::-1]: accum[i+1][j+1] = accum[i+1][j+2]*A[i][j] accum[i+1][j+1] %= mod for i in range(h)[::-1]: for j in range(w)[::-1]: accum[i+1][j+1] *= accum[i+2][j+1] accum[i+1][j+1] %= mod for i,(r,c) in enumerate(Q): ans[i] *= accum[r+1][c+1] accum = [[1]*(w+2) for i in range(h+2)] for i in range(h): for j in range(w)[::-1]: accum[i+1][j+1] = accum[i+1][j+2]*A[i][j] accum[i+1][j+1] %= mod for i in range(h): for j in range(w)[::-1]: accum[i+1][j+1] *= accum[i][j+1] accum[i+1][j+1] %= mod for i,(r,c) in enumerate(Q): ans[i] *= accum[r-1][c+1] accum = [[1]*(w+2) for i in range(h+2)] for i in range(h)[::-1]: for j in range(w): accum[i+1][j+1] = accum[i+1][j]*A[i][j] accum[i+1][j+1] %= mod for i in range(h)[::-1]: for j in range(w): accum[i+1][j+1] *= accum[i+2][j+1] accum[i+1][j+1] %= mod for i,(r,c) in enumerate(Q): ans[i] *= accum[r+1][c-1] for i in ans: print(i%mod)