結果

問題 No.1141 田グリッド
ユーザー convexineqconvexineq
提出日時 2021-05-10 07:20:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 308 ms / 2,000 ms
コード長 617 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 81,704 KB
実行使用メモリ 88,212 KB
最終ジャッジ日時 2023-10-19 15:38:55
合計ジャッジ時間 7,419 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,468 KB
testcase_01 AC 39 ms
53,468 KB
testcase_02 AC 36 ms
53,468 KB
testcase_03 AC 36 ms
53,468 KB
testcase_04 AC 36 ms
53,468 KB
testcase_05 AC 36 ms
53,468 KB
testcase_06 AC 36 ms
53,468 KB
testcase_07 AC 36 ms
53,468 KB
testcase_08 AC 61 ms
66,524 KB
testcase_09 AC 53 ms
64,400 KB
testcase_10 AC 57 ms
66,524 KB
testcase_11 AC 51 ms
64,400 KB
testcase_12 AC 63 ms
68,460 KB
testcase_13 AC 253 ms
88,212 KB
testcase_14 AC 308 ms
82,824 KB
testcase_15 AC 247 ms
78,112 KB
testcase_16 AC 247 ms
78,112 KB
testcase_17 AC 256 ms
78,064 KB
testcase_18 AC 212 ms
77,860 KB
testcase_19 AC 201 ms
76,976 KB
testcase_20 AC 209 ms
77,848 KB
testcase_21 AC 244 ms
78,016 KB
testcase_22 AC 247 ms
78,024 KB
testcase_23 AC 247 ms
78,020 KB
testcase_24 AC 216 ms
77,276 KB
testcase_25 AC 217 ms
77,868 KB
testcase_26 AC 214 ms
77,944 KB
testcase_27 AC 213 ms
77,056 KB
testcase_28 AC 205 ms
78,060 KB
testcase_29 AC 208 ms
77,836 KB
testcase_30 AC 213 ms
77,892 KB
testcase_31 AC 203 ms
77,804 KB
testcase_32 AC 204 ms
77,020 KB
testcase_33 AC 199 ms
77,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10**9+7
h,w = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
r,zr,c,zc = [1]*h, [0]*h, [1]*w, [0]*w
tot = 1
for i in range(h):
    for j in range(w):
        v = a[i][j]
        if v:
            r[i] = r[i]*v%MOD
            c[j] = c[j]*v%MOD
            tot = tot*v%MOD
        else:
            zr[i] += 1
            zc[j] += 1
zt = sum(zr)

Q = int(input())
for _ in range(Q):
    R,C = map(int,input().split())
    R -= 1
    C -= 1
    if zt - zr[R] - zc[C] + (a[R][C]==0):
        print(0)
    else:
        print(tot*pow(r[R]*c[C]%MOD,MOD-2,MOD)%MOD*max(a[R][C],1)%MOD)
0