結果

問題 No.1141 田グリッド
ユーザー itohdakitohdak
提出日時 2020-07-31 21:44:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,141 bytes
コンパイル時間 2,169 ms
コンパイル使用メモリ 204,544 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2023-09-20 22:28:19
合計ジャッジ時間 5,189 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 63 ms
4,380 KB
testcase_14 AC 72 ms
6,272 KB
testcase_15 AC 60 ms
4,384 KB
testcase_16 AC 61 ms
4,380 KB
testcase_17 AC 60 ms
4,376 KB
testcase_18 AC 53 ms
4,380 KB
testcase_19 AC 54 ms
4,376 KB
testcase_20 AC 53 ms
4,376 KB
testcase_21 AC 60 ms
4,376 KB
testcase_22 AC 60 ms
4,380 KB
testcase_23 AC 61 ms
4,376 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;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

ll modinv(ll a, ll m=mod) {
  ll b = m, u = 1, 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() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  vector<vector<ll>> A(h, vector<ll>(w));
  rep(i, h) rep(j, w) cin >> A[i][j];
  int q; cin >> q;
  vector<ll> mulc(h, 1), mulr(w, 1);
  ll mulAll = 1;
  rep(i, h) rep(j, w) (mulc[i] *= A[i][j]) %= mod;
  rep(j, w) rep(i, h) (mulr[j] *= A[i][j]) %= mod;
  rep(i, h) rep(j, w) (mulAll *= A[i][j]) %= mod;
  while(q--) {
    int r, c; cin >> r >> c;
    r--; c--;
    cout << mulAll * modinv(mulc[r]) % mod * modinv(mulr[c]) % mod * A[r][c] % mod << "\n";
  }
  return 0;
}
0