結果

問題 No.1141 田グリッド
ユーザー Fu_LFu_L
提出日時 2021-02-23 01:09:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,169 bytes
コンパイル時間 7,184 ms
コンパイル使用メモリ 266,160 KB
実行使用メモリ 7,020 KB
最終ジャッジ日時 2023-10-21 19:01:34
合計ジャッジ時間 8,248 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,448 KB
testcase_01 AC 2 ms
4,448 KB
testcase_02 AC 3 ms
4,448 KB
testcase_03 AC 3 ms
4,452 KB
testcase_04 AC 3 ms
4,448 KB
testcase_05 AC 2 ms
4,452 KB
testcase_06 AC 3 ms
4,448 KB
testcase_07 AC 3 ms
4,448 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 84 ms
4,828 KB
testcase_19 AC 85 ms
4,828 KB
testcase_20 AC 84 ms
4,828 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
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>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<ll,ll> P;
typedef modint1000000007 mint;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
ll h,w;
vector<vector<ll>> a;
ll q;
ll r,c;
ll zr[100005],zc[100005];
mint pr[100005],pc[100005];
ll p,z;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>h>>w;
    rep(i,0,100005) pr[i]=pc[i]=1;
    p=1;
    a.resize(h);
    rep(y,0,h){
        a[y].resize(w);
        rep(x,0,w){
            cin>>a[y][x];
            if(a[y][x]==0){
                zr[y]++;
                zc[x]++;
                z++;
            }else{
                pr[y]*=a[y][x];
                pc[x]*=a[y][x];
                p*=a[y][x];
            }
        }
    }
    cin>>q;
    while(q--){
        cin>>r>>c;
        r--;
        c--;
        ll tz=z-zr[r]-zc[c];
        if(a[r][c]==0) tz++;
        if(tz>0){
            cout<<0<<endl;
        }else{
            mint ret=p/pr[r]/pc[c];
            if(a[r][c]){
                ret*=a[r][c];
            }
            cout<<ret.val()<<endl;
        }
    }

}
0