結果
問題 | No.1141 田グリッド |
ユーザー |
![]() |
提出日時 | 2020-07-31 22:56:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,022 bytes |
コンパイル時間 | 1,893 ms |
コンパイル使用メモリ | 172,428 KB |
実行使用メモリ | 13,760 KB |
最終ジャッジ日時 | 2024-07-06 20:30:02 |
合計ジャッジ時間 | 5,321 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
13,760 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,948 KB |
testcase_05 | AC | 1 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | AC | 4 ms
6,940 KB |
testcase_09 | AC | 4 ms
6,944 KB |
testcase_10 | AC | 3 ms
6,944 KB |
testcase_11 | AC | 4 ms
6,940 KB |
testcase_12 | AC | 4 ms
6,940 KB |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1000000007; long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long 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; vector<vector<ll>> mp(h, vector<ll>(w)); ll ans = 1; for(int i = 0; i < h; i++){ for(int j = 0; j < w; j++){ cin >> mp[i][j]; ans = ans * mp[i][j] % mod; } } int q; cin >> q; while(q--){ int r, c; cin >> r >> c; r--; c--; ll a = 1, b = 1; for(int i = 0; i < w; i++){ a = a * mp[r][i] % mod; } for(int i = 0; i < h; i++){ b = b * mp[i][c] % mod; } a = modinv(a, mod); b = modinv(b, mod); ll ans1 = ans * a % mod * b % mod * mp[r][c] % mod; cout << ans1 << endl; } }