結果

問題 No.1490 スライムと爆弾
ユーザー merom686merom686
提出日時 2021-04-23 22:37:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 1,575 bytes
コンパイル時間 2,137 ms
コンパイル使用メモリ 202,220 KB
実行使用メモリ 36,448 KB
最終ジャッジ日時 2023-09-17 12:41:54
合計ジャッジ時間 4,606 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,380 KB
testcase_06 AC 2 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,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 50 ms
24,048 KB
testcase_14 AC 58 ms
29,484 KB
testcase_15 AC 34 ms
28,088 KB
testcase_16 AC 43 ms
22,288 KB
testcase_17 AC 27 ms
22,020 KB
testcase_18 AC 57 ms
25,124 KB
testcase_19 AC 54 ms
32,708 KB
testcase_20 AC 41 ms
30,020 KB
testcase_21 AC 27 ms
29,688 KB
testcase_22 AC 51 ms
24,552 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 68 ms
36,448 KB
testcase_26 AC 69 ms
36,324 KB
testcase_27 AC 68 ms
36,372 KB
testcase_28 AC 60 ms
34,748 KB
testcase_29 AC 63 ms
34,616 KB
testcase_30 AC 112 ms
36,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using ll = long long;
using namespace std;

ll s[2001][2001];

struct P {
    int t, u, l, r, a;
};

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

    int h, w, n, m;
    cin >> h >> w >> n >> m;

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        int t, u, l, r, a;
        cin >> t >> u >> l >> r >> a;
        t--; l--;
        t--; u--; l--; r--;

        p[i] = { t, u, l, r, a };
    }

    for (int i = 0; i < m; i++) {
        int x, y, b, c;
        cin >> x >> y >> b >> c;
        int t = max(x - b - 1, 0);
        int u = min(x + b, h);
        int l = max(y - b - 1, 0);
        int r = min(y + b, w);

        s[t][l] += c;
        s[t][r] -= c;
        s[u][l] -= c;
        s[u][r] += c;
    }
    for (int l = 0; l < 2; l++) {
        for (int i = 1; i <= h; i++) {
            for (int j = 0; j <= w; j++) {
                s[i][j] += s[i - 1][j];
            }
        }
        for (int i = 0; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                s[i][j] += s[i][j - 1];
            }
        }
        //for (int i = 0; i <= h; i++) {
        //    for (int j = 0; j <= w; j++) {
        //        cout << s[i][j] << ' ';
        //    }
        //    cout << '\n';
        //}
        //cout << '\n';
    }

    int ans = 0;
    for (auto [t, u, l, r, a] : p) {
        ll c = s[u][r] - (l < 0 ? 0 : s[u][l]) - (t < 0 ? 0 : s[t][r]) + (l < 0 || t < 0 ? 0 : s[t][l]);
        //cout << c << ' ' << a << endl;
        ans += c < a;
    }

    cout << ans << endl;

    return 0;
}
0