結果

問題 No.1490 スライムと爆弾
ユーザー MisterMister
提出日時 2021-04-23 21:56:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 1,592 bytes
コンパイル時間 885 ms
コンパイル使用メモリ 85,128 KB
実行使用メモリ 36,932 KB
最終ジャッジ日時 2023-09-17 12:10:06
合計ジャッジ時間 3,727 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 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,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 58 ms
17,512 KB
testcase_14 AC 69 ms
23,028 KB
testcase_15 AC 43 ms
18,864 KB
testcase_16 AC 46 ms
13,260 KB
testcase_17 AC 40 ms
21,528 KB
testcase_18 AC 70 ms
23,088 KB
testcase_19 AC 63 ms
21,004 KB
testcase_20 AC 48 ms
17,644 KB
testcase_21 AC 33 ms
16,952 KB
testcase_22 AC 55 ms
15,108 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 95 ms
36,776 KB
testcase_26 AC 92 ms
36,892 KB
testcase_27 AC 93 ms
36,716 KB
testcase_28 AC 83 ms
34,364 KB
testcase_29 AC 86 ms
34,508 KB
testcase_30 AC 139 ms
36,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <tuple>

using namespace std;
using lint = long long;

void solve() {
    int h, w, n, m;
    cin >> h >> w >> n >> m;

    vector<tuple<int, int, int, int, lint>> slimes(n);
    for (auto& [lx, rx, ly, ry, t] : slimes) {
        cin >> lx >> rx >> ly >> ry >> t;
    }

    auto grid = vector(h + 2, vector(w + 2, 0LL));
    while (m--) {
        int cx, cy, b;
        cin >> cx >> cy >> b;

        auto lx = max(1, cx - b), rx = min(h, cx + b),
             ly = max(1, cy - b), ry = min(w, cy + b);

        lint c;
        cin >> c;
        grid[lx][ly] += c, grid[lx][ry + 1] -= c;
        grid[rx + 1][ly] -= c, grid[rx + 1][ry + 1] += c;
    }

    for (int x = 0; x < h + 2; ++x) {
        for (int y = 1; y < w + 2; ++y) {
            grid[x][y] += grid[x][y - 1];
        }
    }
    for (int x = 1; x < h + 2; ++x) {
        for (int y = 0; y < w + 2; ++y) {
            grid[x][y] += grid[x - 1][y];
        }
    }
    for (int x = 0; x < h + 2; ++x) {
        for (int y = 1; y < w + 2; ++y) {
            grid[x][y] += grid[x][y - 1];
        }
    }
    for (int x = 1; x < h + 2; ++x) {
        for (int y = 0; y < w + 2; ++y) {
            grid[x][y] += grid[x - 1][y];
        }
    }

    int ans = 0;
    for (auto [lx, rx, ly, ry, t] : slimes) {
        auto sum = grid[rx][ry] - grid[rx][ly - 1] -
                   grid[lx - 1][ry] + grid[lx - 1][ly - 1];
        if (sum < t) ++ans;
    }

    cout << ans << "\n";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}
0