結果

問題 No.1141 田グリッド
ユーザー anagohirameanagohirame
提出日時 2020-07-31 22:37:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 816 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,316 KB
実行使用メモリ 89,372 KB
最終ジャッジ日時 2023-09-21 01:07:50
合計ジャッジ時間 6,618 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,224 KB
testcase_01 AC 72 ms
71,292 KB
testcase_02 AC 72 ms
71,440 KB
testcase_03 AC 71 ms
71,224 KB
testcase_04 AC 72 ms
71,328 KB
testcase_05 AC 71 ms
71,296 KB
testcase_06 AC 72 ms
71,404 KB
testcase_07 AC 72 ms
71,516 KB
testcase_08 AC 84 ms
76,792 KB
testcase_09 AC 83 ms
76,860 KB
testcase_10 AC 84 ms
76,692 KB
testcase_11 AC 82 ms
76,568 KB
testcase_12 AC 88 ms
76,720 KB
testcase_13 AC 230 ms
89,372 KB
testcase_14 AC 255 ms
84,652 KB
testcase_15 AC 209 ms
78,692 KB
testcase_16 AC 212 ms
78,956 KB
testcase_17 AC 213 ms
78,772 KB
testcase_18 AC 120 ms
78,416 KB
testcase_19 AC 120 ms
78,508 KB
testcase_20 AC 120 ms
78,536 KB
testcase_21 AC 209 ms
78,652 KB
testcase_22 AC 206 ms
78,824 KB
testcase_23 AC 209 ms
78,680 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 #

import sys
def input():
	return sys.stdin.buffer.readline()[:-1]

MOD = 10**9+7

H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]

r_zero = [0 for _ in range(H)]
c_zero = [0 for _ in range(W)]
r = [1 for _ in range(H)]
c = [1 for _ in range(W)]
tot = 1
for h in range(H):
	for w in range(W):
		if a[h][w] == 0:
			r_zero[h] = 1
			c_zero[w] = 1
		else:
			r[h] *= a[h][w]
			r[h] %= MOD
			c[w] *= a[h][w]
			c[w] %= MOD
			tot *= a[h][w]
			tot %= MOD
r_zero_sum = sum(r_zero)
c_zero_sum = sum(c_zero)

for _ in range(int(input())):
	x, y = map(int, input().split())
	x, y = x-1, y-1
	res = tot
	if r_zero_sum - r_zero[x] or c_zero_sum - c_zero[y]:
		print(0)
	else:
		res *= pow(r[x], MOD-2, MOD) * pow(c[y], MOD-2, MOD)
		if a[x][y] != 0:
			res *= a[x][y]
		print(res%MOD)
0