結果

問題 No.1141 田グリッド
ユーザー leaf_1415leaf_1415
提出日時 2020-07-31 21:33:20
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,530 bytes
コンパイル時間 1,489 ms
コンパイル使用メモリ 74,892 KB
実行使用メモリ 4,732 KB
最終ジャッジ日時 2023-09-20 21:57:15
合計ジャッジ時間 6,259 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 143 ms
4,584 KB
testcase_14 AC 143 ms
4,732 KB
testcase_15 AC 142 ms
4,376 KB
testcase_16 AC 142 ms
4,384 KB
testcase_17 AC 142 ms
4,376 KB
testcase_18 AC 141 ms
4,380 KB
testcase_19 AC 140 ms
4,380 KB
testcase_20 AC 140 ms
4,376 KB
testcase_21 AC 143 ms
4,380 KB
testcase_22 AC 141 ms
4,376 KB
testcase_23 AC 142 ms
4,376 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 #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint Q;
llint h, w;
llint a[100005];
llint r[100005], c[100005];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> h >> w;
	llint mul = 1;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> a[i*w+j];
			mul *= a[i*w+j], mul %= mod;
		}
	}
	for(int i = 0; i < h; i++){
		r[i] = 1;
		for(int j = 0; j < w; j++) r[i] *= a[i*w+j], r[i] %= mod;
	}
	for(int i = 0; i < w; i++){
		c[i] = 1;
		for(int j = 0; j < h; j++) c[i] *= a[j*w+i], c[i] %= mod;
	}
	
	cin >> Q;
	llint x, y;
	for(int i = 0; i < Q; i++){
		cin >> y >> x;
		x--, y--;
		llint ans = mul;
		ans *= modpow(r[y], mod-2), ans %= mod;
		ans *= modpow(c[x], mod-2), ans %= mod;
		ans *= a[y*w+x], ans %= mod;
		cout << ans << endl;
	}

	return 0;
}
0