結果

問題 No.1490 スライムと爆弾
ユーザー suisensuisen
提出日時 2021-04-23 21:48:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,066 bytes
コンパイル時間 2,195 ms
コンパイル使用メモリ 209,648 KB
実行使用メモリ 36,576 KB
最終ジャッジ日時 2023-09-17 12:03:24
合計ジャッジ時間 5,835 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1 ms
4,380 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 130 ms
34,444 KB
testcase_29 AC 131 ms
34,444 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

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 + 1, 1), d = min(cr + k + 1, h);
        int l = max(cc - k + 1, 1), 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];
    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];
    int ans = 0;
    for (auto &[u, d, l, r, a] : slimes) {
        long long t = s[d][r] - s[d][l] - s[u][r] + s[u][l];
        ans += t < a;
    }
    cout << ans << '\n';
    return 0;
}
0