結果

問題 No.1141 田グリッド
ユーザー googol_S0googol_S0
提出日時 2020-08-01 00:45:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 632 bytes
コンパイル時間 1,384 ms
コンパイル使用メモリ 86,704 KB
実行使用メモリ 95,324 KB
最終ジャッジ日時 2023-09-21 04:26:14
合計ジャッジ時間 6,885 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
70,940 KB
testcase_01 AC 72 ms
71,256 KB
testcase_02 AC 74 ms
71,264 KB
testcase_03 AC 74 ms
71,064 KB
testcase_04 AC 72 ms
71,152 KB
testcase_05 AC 72 ms
71,152 KB
testcase_06 AC 73 ms
71,168 KB
testcase_07 AC 72 ms
70,936 KB
testcase_08 AC 85 ms
76,404 KB
testcase_09 AC 84 ms
76,592 KB
testcase_10 AC 85 ms
76,248 KB
testcase_11 AC 82 ms
76,436 KB
testcase_12 AC 90 ms
76,328 KB
testcase_13 AC 196 ms
95,324 KB
testcase_14 AC 233 ms
93,928 KB
testcase_15 AC 188 ms
84,588 KB
testcase_16 AC 186 ms
84,680 KB
testcase_17 AC 183 ms
85,088 KB
testcase_18 AC 135 ms
85,024 KB
testcase_19 AC 141 ms
84,384 KB
testcase_20 AC 137 ms
84,360 KB
testcase_21 AC 184 ms
84,460 KB
testcase_22 AC 181 ms
84,360 KB
testcase_23 AC 182 ms
84,564 KB
testcase_24 AC 146 ms
85,140 KB
testcase_25 AC 146 ms
84,460 KB
testcase_26 AC 146 ms
85,024 KB
testcase_27 AC 149 ms
85,176 KB
testcase_28 AC 146 ms
84,676 KB
testcase_29 AC 141 ms
84,384 KB
testcase_30 AC 143 ms
84,992 KB
testcase_31 AC 150 ms
84,156 KB
testcase_32 AC 141 ms
84,412 KB
testcase_33 AC 139 ms
84,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
S=sys.stdin.readlines()
H,W=map(int,S[0].split())
A=[list(map(int,S[i+1].split())) for i in range(H)]
mod=10**9+7
M1=[1]*H
C1=[0]*H
M2=[1]*W
C2=[0]*W
MA=1
CA=0
for i in range(H):
  for j in range(W):
    if A[i][j]:
      M1[i]=M1[i]*A[i][j]%mod
      M2[j]=M2[j]*A[i][j]%mod
      MA=MA*A[i][j]%mod
    else:
      C1[i]+=1
      C2[j]+=1
      CA+=1
Q=int(S[H+1])
r,c=0,0
for i in range(Q):
  r,c=map(int,S[H+2+i].split())
  r,c=r-1,c-1
  if CA-C1[r]-C2[c]+(A[r][c]==0):
    print(0)
  else:
    if A[r][c]:
      print(MA*pow(M1[r]*M2[c],mod-2,mod)*A[r][c]%mod)
    else:
      print(MA*pow(M1[r]*M2[c],mod-2,mod)%mod)
0