結果
問題 | No.1141 田グリッド |
ユーザー | sepa38 |
提出日時 | 2023-03-28 11:21:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,138 ms / 2,000 ms |
コード長 | 1,611 bytes |
コンパイル時間 | 4,063 ms |
コンパイル使用メモリ | 235,616 KB |
実行使用メモリ | 7,700 KB |
最終ジャッジ日時 | 2023-10-20 06:35:27 |
合計ジャッジ時間 | 21,665 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | AC | 2 ms
4,348 KB |
testcase_05 | AC | 2 ms
4,348 KB |
testcase_06 | AC | 2 ms
4,348 KB |
testcase_07 | AC | 2 ms
4,348 KB |
testcase_08 | AC | 5 ms
4,348 KB |
testcase_09 | AC | 3 ms
4,348 KB |
testcase_10 | AC | 5 ms
4,348 KB |
testcase_11 | AC | 6 ms
4,348 KB |
testcase_12 | AC | 4 ms
4,348 KB |
testcase_13 | AC | 157 ms
7,700 KB |
testcase_14 | AC | 159 ms
7,700 KB |
testcase_15 | AC | 697 ms
6,816 KB |
testcase_16 | AC | 651 ms
6,552 KB |
testcase_17 | AC | 529 ms
5,760 KB |
testcase_18 | AC | 557 ms
6,024 KB |
testcase_19 | AC | 648 ms
6,552 KB |
testcase_20 | AC | 642 ms
6,552 KB |
testcase_21 | AC | 1,129 ms
6,816 KB |
testcase_22 | AC | 1,126 ms
6,816 KB |
testcase_23 | AC | 1,138 ms
6,816 KB |
testcase_24 | AC | 940 ms
6,288 KB |
testcase_25 | AC | 285 ms
6,552 KB |
testcase_26 | AC | 551 ms
6,024 KB |
testcase_27 | AC | 523 ms
6,024 KB |
testcase_28 | AC | 292 ms
6,552 KB |
testcase_29 | AC | 921 ms
6,024 KB |
testcase_30 | AC | 524 ms
6,024 KB |
testcase_31 | AC | 771 ms
7,344 KB |
testcase_32 | AC | 1,135 ms
6,816 KB |
testcase_33 | AC | 1,113 ms
6,816 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; long long op(long long a, long long b){ return a * b % 1000000007; } long long e(){ return 1; } int main(){ long long h, w; cin >> h >> w; long long a[h][w]; for (int i = 0; i < h; i++){ for (int j = 0; j < w; j++){ cin >> a[i][j]; } } long long mod = 1000000007; if (h < w){ vector<segtree<long long, op, e>> seg; for (int i = 0; i < h; i++){ segtree<long long, op, e> tmp(w); for (int j = 0; j < w; j++){ tmp.set(j, a[i][j]); } seg.push_back(tmp); } long long q; cin >> q; for (int cnt = 0; cnt < q; cnt++){ long long r, c; cin >> r >> c; r -= 1; c -= 1; long long ans = 1; for (int i = 0; i < h; i++){ if (i == r){ continue; } ans *= seg[i].prod(0, c) * seg[i].prod(c+1, w) % mod; ans %= mod; } cout << ans << endl; } } else{ vector<segtree<long long, op, e>> seg; for (int j = 0; j < w; j++){ segtree<long long, op, e> tmp(h); for (int i = 0; i < h; i++){ tmp.set(i, a[i][j]); } seg.push_back(tmp); } long long q; cin >> q; for (int cnt = 0; cnt < q; cnt++){ long long r, c; cin >> r >> c; r -= 1; c -= 1; long long ans = 1; for (int j = 0; j < w; j++){ if (j == c){ continue; } ans *= seg[j].prod(0, r) * seg[j].prod(r+1, h) % mod; ans %= mod; } cout << ans << endl; } } }