結果

問題 No.1141 田グリッド
ユーザー googol_S0googol_S0
提出日時 2020-08-01 00:41:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 557 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 86,788 KB
実行使用メモリ 95,208 KB
最終ジャッジ日時 2023-09-21 04:24:59
合計ジャッジ時間 6,643 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,120 KB
testcase_01 AC 72 ms
71,356 KB
testcase_02 AC 72 ms
71,264 KB
testcase_03 AC 72 ms
71,124 KB
testcase_04 AC 74 ms
71,188 KB
testcase_05 AC 75 ms
71,028 KB
testcase_06 AC 74 ms
70,972 KB
testcase_07 AC 74 ms
70,804 KB
testcase_08 AC 97 ms
76,480 KB
testcase_09 AC 82 ms
76,492 KB
testcase_10 AC 87 ms
76,336 KB
testcase_11 AC 82 ms
76,512 KB
testcase_12 AC 92 ms
76,404 KB
testcase_13 AC 191 ms
95,208 KB
testcase_14 AC 232 ms
94,024 KB
testcase_15 AC 184 ms
84,792 KB
testcase_16 AC 185 ms
84,772 KB
testcase_17 AC 186 ms
85,212 KB
testcase_18 AC 135 ms
85,008 KB
testcase_19 AC 138 ms
84,628 KB
testcase_20 AC 135 ms
84,612 KB
testcase_21 AC 181 ms
84,492 KB
testcase_22 AC 182 ms
84,448 KB
testcase_23 AC 182 ms
84,828 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 146 ms
85,256 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 141 ms
84,456 KB
testcase_33 AC 144 ms
84,652 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:
    print(MA*pow(M1[r]*M2[c],mod-2,mod)*A[r][c]%mod)
0