結果

問題 No.1490 スライムと爆弾
ユーザー suisensuisen
提出日時 2021-04-23 21:55:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 290 ms / 2,000 ms
コード長 2,128 bytes
コンパイル時間 2,510 ms
コンパイル使用メモリ 210,660 KB
実行使用メモリ 67,968 KB
最終ジャッジ日時 2023-09-17 12:09:53
合計ジャッジ時間 6,045 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 126 ms
31,420 KB
testcase_14 AC 155 ms
40,500 KB
testcase_15 AC 84 ms
33,900 KB
testcase_16 AC 112 ms
21,852 KB
testcase_17 AC 74 ms
39,468 KB
testcase_18 AC 156 ms
40,612 KB
testcase_19 AC 137 ms
37,020 KB
testcase_20 AC 100 ms
31,120 KB
testcase_21 AC 63 ms
29,940 KB
testcase_22 AC 132 ms
25,476 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 193 ms
67,968 KB
testcase_26 AC 195 ms
67,636 KB
testcase_27 AC 190 ms
67,684 KB
testcase_28 AC 148 ms
65,936 KB
testcase_29 AC 153 ms
65,940 KB
testcase_30 AC 290 ms
67,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using int128 = __int128_t;

#define rep(i, n)         for (int i = 0; i < n; ++i)
#define reps(i, n, s)     for (int i = 0; i < n; i += s)
#define repl(i, l, r)     for (int i = l; i < r; ++i)
#define repsl(i, l, r, s) for (int i = l; i < r; i += s)

#define all(iterable) (iterable).begin(), (iterable).end()

constexpr int dx4[4] = {1, 0, -1, 0};
constexpr int dy4[4] = {0, 1, 0, -1};

constexpr int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

template <typename T>
void print(const vector<T>& vec, const string sep = " ", const string end = "\n") {
    int n = vec.size();
    rep(i, n) {
        cout << vec[i];
        if (i < n - 1) cout << sep;
        else cout << end;
    }
}

template <typename T>
void read(vector<T>& a, int begin_index, int length) {
    if (a.size() < begin_index + length) a.resize(begin_index + length);
    while (length --> 0) cin >> a[begin_index++];
}
template <typename T>
void read(vector<T>& a) { read(a, 0, a.size()); }

int main() {
    int h, w, n, m;
    cin >> h >> w >> n >> m;
    vector<vector<long long>> s(h + 1, vector<long long>(w + 1, 0));
    vector<tuple<int, int, int, int, int>> slimes(n);
    rep(i, n) {
        int u, d, l, r, a;
        cin >> u >> d >> l >> r >> a;
        slimes[i] = {u - 1, d, l - 1, r, a};
    }
    rep(i, m) {
        int cr, cc, k, x;
        cin >> cr >> cc >> k >> x;
        --cr, --cc;
        int u = max(cr - k, 0), d = min(cr + k + 1, h);
        int l = max(cc - k, 0), r = min(cc + k + 1, w);
        s[u][l] += x; s[u][r] -= x;
        s[d][l] -= x; s[d][r] += x;
    }
    rep(i, h) rep(j, w + 1) s[i + 1][j] += s[i][j];
    rep(i, h + 1) rep(j, w) s[i][j + 1] += s[i][j];
    vector<vector<long long>> t(h + 1, vector<long long>(w + 1, 0));
    rep(i, h) rep(j, w) {
        t[i + 1][j + 1] = s[i][j] + t[i + 1][j] + t[i][j + 1] - t[i][j];
    }
    int ans = 0;
    for (auto &[u, d, l, r, a] : slimes) {
        long long x = t[d][r] - t[d][l] - t[u][r] + t[u][l];
        ans += x < a;
    }
    cout << ans << '\n';
    return 0;
}
0