結果

問題 No.1141 田グリッド
ユーザー yuji9511yuji9511
提出日時 2020-07-31 22:18:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,542 bytes
コンパイル時間 2,076 ms
コンパイル使用メモリ 204,528 KB
実行使用メモリ 7,436 KB
最終ジャッジ日時 2023-09-20 23:52:39
合計ジャッジ時間 4,926 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,932 KB
testcase_01 AC 2 ms
4,936 KB
testcase_02 AC 2 ms
4,948 KB
testcase_03 AC 2 ms
4,940 KB
testcase_04 AC 3 ms
4,984 KB
testcase_05 AC 3 ms
4,924 KB
testcase_06 AC 2 ms
4,920 KB
testcase_07 AC 3 ms
4,928 KB
testcase_08 AC 3 ms
5,048 KB
testcase_09 AC 4 ms
5,024 KB
testcase_10 AC 3 ms
5,132 KB
testcase_11 AC 4 ms
5,072 KB
testcase_12 AC 3 ms
5,200 KB
testcase_13 AC 50 ms
5,608 KB
testcase_14 AC 57 ms
7,436 KB
testcase_15 AC 48 ms
5,456 KB
testcase_16 AC 49 ms
5,400 KB
testcase_17 AC 47 ms
5,472 KB
testcase_18 AC 46 ms
5,404 KB
testcase_19 AC 46 ms
5,428 KB
testcase_20 AC 46 ms
5,400 KB
testcase_21 AC 48 ms
5,416 KB
testcase_22 AC 48 ms
5,556 KB
testcase_23 AC 48 ms
5,404 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 #

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll power(ll x, ll n){
    if(n == 0) return 1LL;
    ll res = power(x * x % MOD, n/2);
    if(n % 2 == 1) res = res * x % MOD;
    return res;
}

void solve(){
    ll H,W;
    cin >> H >> W;
    vector< vector<ll> > A(H+1, vector<ll>(W+1));
    rep(i,0,H){
        rep(j,0,W){
            cin >> A[i][j];
        }
    }
    ll Q;
    cin >> Q;
    ll mul = 1;
    rep(i,0,H){
        rep(j,0,W){
            mul *= A[i][j];
            mul %= MOD;
        }
    }
    ll tate[100010] = {}, yoko[100010] = {};
    rep(i,0,H){
        ll res = 1;
        rep(j,0,W){
            res *= A[i][j];
            res %= MOD;
        }
        tate[i] = res;
    }
    rep(j,0,W){
        ll res = 1;
        rep(i,0,H){
            res *= A[i][j];
            res %= MOD;
        }
        yoko[j] = res;
    }
    while(Q--){
        ll r,c;
        cin >> r >> c;
        r--; c--;
        ll ans = mul * power(tate[r],MOD-2) % MOD * power(yoko[c], MOD-2) % MOD * A[r][c] % MOD;
        print(ans);

    }
    

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
0