結果

問題 No.1141 田グリッド
ユーザー hs0319boyhs0319boy
提出日時 2020-07-31 22:48:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,433 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 172,356 KB
実行使用メモリ 6,904 KB
最終ジャッジ日時 2023-09-21 01:27:56
合計ジャッジ時間 6,729 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 8 ms
4,380 KB
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 161 ms
4,972 KB
testcase_14 AC 170 ms
6,904 KB
testcase_15 AC 156 ms
4,476 KB
testcase_16 AC 157 ms
4,444 KB
testcase_17 AC 157 ms
4,404 KB
testcase_18 AC 155 ms
4,428 KB
testcase_19 AC 155 ms
4,460 KB
testcase_20 AC 157 ms
4,416 KB
testcase_21 AC 156 ms
4,408 KB
testcase_22 AC 158 ms
4,440 KB
testcase_23 AC 159 ms
4,732 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;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

ll mondiv(ll a,ll m=inf){
    ll b=m;ll u=1;ll v=0;
    while(b){
        ll t=a/b;
        a-=t*b;swap(a,b);
        u-=t*v;swap(u,v);
    }
    u%=m;
    if(u<0)u+=m;
    return u;
}

int main(){
    int h,w;cin>>h>>w;
    vvll a(h,vll(w));
    vll row(h,(ll)1),column(w,(ll)1);
    ll ap=(ll)1;ll tmp;
    rep(i,h)rep(j,w){
        cin>>a[i][j];
        ap*=a[i][j];ap%=inf;
        tmp=mondiv(a[i][j]);
        row[i]*=tmp;row[i]%=inf;
        column[j]*=tmp;column[j]%=inf;
    }
    int q;cin>>q;
    vll ans;int r,c;
    rep(i,q){
        cin>>r>>c;r--;c--;
        tmp=ap*row[r];tmp%=inf;
        tmp*=column[c];tmp%=inf;
        tmp*=a[r][c];tmp%=inf;
        ans.push_back(tmp);
    }
    rep(i,ans.size())cout<<ans[i]<<endl;
}
0