結果

問題 No.1141 田グリッド
ユーザー yutasyutas
提出日時 2020-07-31 22:13:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,442 bytes
コンパイル時間 1,558 ms
コンパイル使用メモリ 169,460 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-20 23:45:00
合計ジャッジ時間 6,854 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 158 ms
4,376 KB
testcase_14 AC 161 ms
4,376 KB
testcase_15 AC 154 ms
4,376 KB
testcase_16 AC 154 ms
4,376 KB
testcase_17 AC 154 ms
4,376 KB
testcase_18 AC 153 ms
4,380 KB
testcase_19 AC 152 ms
4,380 KB
testcase_20 AC 151 ms
4,380 KB
testcase_21 AC 156 ms
4,380 KB
testcase_22 AC 155 ms
4,380 KB
testcase_23 AC 154 ms
4,408 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;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A*A%MOD, N/2);
  return Pow(A*A%MOD, N/2)*A%MOD;
}

int main(){
  int H, W; cin >> H >> W;
  ll A[H][W], sum = 1;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> A[i][j];
      sum *= A[i][j]; sum %= MOD;
    }
  }

  vector <ll> h(H), w(W);
  for (int i = 0; i < H; i++){
    ll now = 1;
    for (int j = 0; j < W; j++){
      now *= A[i][j]; now %= MOD;
    }
    h[i] = now;
  }
  for (int j = 0; j < W; j++){
    ll now = 1;
    for (int i = 0; i < H; i++){
      now *= A[i][j]; now %= MOD;
    }
    w[j] = now; 
  }

  int Q; cin >> Q;
  for (int i = 0; i < Q; i++){
    int r, c; cin >> r >> c;
    ll ans = sum;
    ans *= Pow(h[r-1], MOD-2); ans %= MOD;
    ans *= Pow(w[c-1], MOD-2); ans %= MOD;
    ans *= A[r-1][c-1]; ans %= MOD;
    cout << ans << endl;
  }


  return 0;
}
0