結果

問題 No.1141 田グリッド
ユーザー rlangevinrlangevin
提出日時 2023-01-31 00:11:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,164 bytes
コンパイル時間 782 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 89,668 KB
最終ジャッジ日時 2023-09-12 20:18:29
合計ジャッジ時間 8,439 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,220 KB
testcase_01 AC 71 ms
71,120 KB
testcase_02 AC 71 ms
71,372 KB
testcase_03 AC 71 ms
71,248 KB
testcase_04 AC 70 ms
71,120 KB
testcase_05 AC 71 ms
70,992 KB
testcase_06 AC 70 ms
71,272 KB
testcase_07 AC 71 ms
71,176 KB
testcase_08 AC 101 ms
76,724 KB
testcase_09 AC 95 ms
76,608 KB
testcase_10 AC 96 ms
76,928 KB
testcase_11 AC 94 ms
76,660 KB
testcase_12 AC 98 ms
76,580 KB
testcase_13 AC 311 ms
89,668 KB
testcase_14 AC 382 ms
84,304 KB
testcase_15 AC 258 ms
79,116 KB
testcase_16 AC 258 ms
79,144 KB
testcase_17 AC 256 ms
79,200 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 254 ms
79,052 KB
testcase_22 AC 255 ms
78,952 KB
testcase_23 AC 253 ms
79,244 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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
mod = 10 ** 9 + 7
A = []
ans = 1
zx, zy = -1, -1
for i in range(H):
    A.append(list(map(int, input().split())))
    for j in range(W):
        ans *= A[i][j]
        ans %= mod
        if A[i][j] == 0:
            if zx == -1:
                zx, zy = i, j
            else:
                print(0)
                exit()

if zx != -1:
    ans = 1
    for i in range(H):
        for j in range(W):
            if i == zx:
                continue
            if j == zy:
                continue
            ans *= A[i][j]
            ans %= mod
            
        
DH, DW = [1] * H, [1] * W
for i in range(H):
    for j in range(W):
        DH[i] *= A[i][j]
        DH[i] %= mod
        DW[j] *= A[i][j]
        DW[j] %= mod
    
for i in range(H):
    DH[i] = pow(DH[i], mod - 2, mod)
for j in range(W):
    DW[j] = pow(DW[j], mod - 2, mod)
        
    
Q = int(input())
for i in range(Q):
    r, c = map(int, input().split())
    r, c = r - 1 , c - 1
    if zx == -1:
        print(ans * DH[r] * DW[c] * A[r][c] % mod)
    else:
        if zx == r and zy == c:
            print(ans)
        else:
            print(0)    
0