結果
| 問題 |
No.1141 田グリッド
|
| コンテスト | |
| ユーザー |
leaf_1415
|
| 提出日時 | 2020-07-31 21:33:20 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,530 bytes |
| コンパイル時間 | 716 ms |
| コンパイル使用メモリ | 80,752 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-06 16:44:06 |
| 合計ジャッジ時間 | 4,813 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 10 |
ソースコード
#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;
}
leaf_1415