結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,272 KB
testcase_01 AC 73 ms
71,340 KB
testcase_02 AC 73 ms
71,372 KB
testcase_03 AC 72 ms
71,100 KB
testcase_04 AC 74 ms
71,572 KB
testcase_05 AC 75 ms
71,344 KB
testcase_06 AC 72 ms
71,588 KB
testcase_07 AC 72 ms
71,124 KB
testcase_08 AC 86 ms
76,900 KB
testcase_09 AC 84 ms
76,724 KB
testcase_10 AC 86 ms
76,828 KB
testcase_11 AC 85 ms
76,700 KB
testcase_12 AC 88 ms
76,820 KB
testcase_13 AC 225 ms
89,784 KB
testcase_14 AC 261 ms
84,620 KB
testcase_15 AC 211 ms
78,908 KB
testcase_16 AC 212 ms
78,832 KB
testcase_17 AC 212 ms
78,812 KB
testcase_18 AC 123 ms
78,380 KB
testcase_19 AC 125 ms
78,512 KB
testcase_20 AC 122 ms
78,496 KB
testcase_21 AC 213 ms
78,872 KB
testcase_22 AC 211 ms
78,948 KB
testcase_23 AC 212 ms
78,916 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 138 ms
79,148 KB
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)]
tot_zero = 0
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
			tot_zero += 1
		else:
			r[h] *= a[h][w]
			r[h] %= MOD
			c[w] *= a[h][w]
			c[w] %= MOD
			tot *= a[h][w]
			tot %= MOD

for _ in range(int(input())):
	x, y = map(int, input().split())
	x, y = x-1, y-1
	res = tot
	if r_zero[x] + c_zero[y] - (a[h][w] == 0) != tot_zero:
		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