結果

問題 No.1490 スライムと爆弾
ユーザー t33ft33f
提出日時 2021-04-23 22:33:36
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 270 ms / 2,000 ms
コード長 1,314 bytes
コンパイル時間 770 ms
コンパイル使用メモリ 85,448 KB
実行使用メモリ 38,136 KB
最終ジャッジ日時 2023-09-17 12:39:30
合計ジャッジ時間 4,488 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 118 ms
18,260 KB
testcase_14 AC 146 ms
23,688 KB
testcase_15 AC 75 ms
18,808 KB
testcase_16 AC 107 ms
13,364 KB
testcase_17 AC 64 ms
21,472 KB
testcase_18 AC 147 ms
23,988 KB
testcase_19 AC 129 ms
22,184 KB
testcase_20 AC 93 ms
18,176 KB
testcase_21 AC 56 ms
17,144 KB
testcase_22 AC 128 ms
16,420 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 175 ms
37,424 KB
testcase_26 AC 174 ms
37,144 KB
testcase_27 AC 174 ms
37,464 KB
testcase_28 AC 130 ms
34,396 KB
testcase_29 AC 133 ms
34,412 KB
testcase_30 AC 270 ms
38,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <tuple>
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int h, w, n, m; cin >> h >> w >> n >> m;
    vector sum(h+1, vector<long long>(w+1, 0));
    vector<tuple<int, int, int, int, int> > queries;
    for (int i = 0; i < n; i++) {
        int x1, x2, y1, y2, a; cin >> x1 >> x2 >> y1 >> y2 >> a;
        queries.emplace_back(x1-1, x2-1, y1-1, y2-1, a);
    }
    for (int i = 0; i < m; i++) {
        int x, y, b, c; cin >> x >> y >> b >> c;
        const int x1 = max(0, x - 1 - b), x2 = min(h, x + b),
            y1 = max(0, y - 1 - b), y2 = min(w, y + b);
        sum[x1][y1] += c;
        sum[x1][y2] -= c;
        sum[x2][y1] -= c;
        sum[x2][y2] += c;
    }
    for (int t = 0; t < 2; t++) {
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (i > 0) sum[i][j] += sum[i-1][j];
                if (j > 0) sum[i][j] += sum[i][j-1];
                if (i > 0 && j > 0) sum[i][j] -= sum[i-1][j-1];
            }
        }
    }

    int ans = n;
    for (auto [x1, x2, y1, y2, a] : queries) {
        long long s = sum[x2][y2];
        if (x1 > 0) s -= sum[x1-1][y2];
        if (y1 > 0) s -= sum[x2][y1-1];
        if (x1 > 0 && y1 > 0) s += sum[x1-1][y1-1];
        if (s >= a) ans--;
    }
    cout << ans << endl;
}
0