結果

問題 No.1141 田グリッド
ユーザー ttkkggwwttkkggww
提出日時 2020-07-31 22:24:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 898 bytes
コンパイル時間 1,723 ms
コンパイル使用メモリ 171,936 KB
実行使用メモリ 8,844 KB
最終ジャッジ日時 2023-09-21 00:00:47
合計ジャッジ時間 6,790 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 7 ms
4,380 KB
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 157 ms
5,260 KB
testcase_14 AC 172 ms
8,844 KB
testcase_15 AC 153 ms
5,272 KB
testcase_16 AC 154 ms
4,980 KB
testcase_17 AC 154 ms
5,044 KB
testcase_18 AC 152 ms
5,000 KB
testcase_19 AC 152 ms
5,032 KB
testcase_20 AC 152 ms
5,020 KB
testcase_21 AC 155 ms
5,000 KB
testcase_22 AC 157 ms
5,080 KB
testcase_23 AC 154 ms
4,908 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 <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T> T mod_pow(T x, T n, const T &p)
{
	T ret = 1;
	while (n > 0)
	{
		if (n & 1) (ret *= x) %= p;
		(x *= x) %= p;
		n >>= 1;
	}
	return ret;
}

const ll MOD = 1e9+7;

int main()
{
	int h,w;
	cin >> h >> w;
	vector<vector<ll>> A(h,vector<ll>(w)),ans(h,vector<ll>(w));
	ll all = 1;
	for(int i = 0;i<h;i++)
	{
		for(int j =0;j<w;j++)
		{
			cin >> A[i][j];
			all = all*A[i][j]%MOD;
		}
	}
	vector<ll> row(h,1),col(w,1);
	for(int i = 0;i<h;i++)for(int j = 0;j<w;j++)
	{
		row[i] = row[i]*mod_pow(A[i][j],MOD-2,MOD)%MOD;
	}
	for(int i = 0;i<h;i++)for(int j = 0;j<w;j++)
	{
		col[j] = col[j]*mod_pow(A[i][j],MOD-2,MOD)%MOD;
	}
	int q;
	cin >> q;
	while(q--)
	{
		ll r,c;
		cin >>r >> c;
		r--;c--;
		ll a = 1;
		a = a*row[r]%MOD;
		a = a*col[c]%MOD;
		a = a*A[r][c]%MOD;
		a = a*all%MOD;
		cout << a << endl;
	}


}
0