結果

問題 No.1490 スライムと爆弾
ユーザー milanis48663220milanis48663220
提出日時 2021-04-23 22:45:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,072 bytes
コンパイル時間 861 ms
コンパイル使用メモリ 94,888 KB
実行使用メモリ 66,164 KB
最終ジャッジ日時 2023-09-17 12:47:19
合計ジャッジ時間 5,707 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,476 KB
testcase_01 AC 2 ms
5,456 KB
testcase_02 AC 3 ms
7,904 KB
testcase_03 AC 2 ms
5,772 KB
testcase_04 AC 2 ms
5,820 KB
testcase_05 AC 3 ms
7,888 KB
testcase_06 AC 2 ms
5,560 KB
testcase_07 AC 2 ms
5,712 KB
testcase_08 AC 2 ms
5,708 KB
testcase_09 AC 2 ms
5,712 KB
testcase_10 AC 2 ms
5,528 KB
testcase_11 AC 3 ms
5,600 KB
testcase_12 AC 3 ms
5,692 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 2 ms
5,516 KB
testcase_24 AC 2 ms
5,384 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 66 ms
66,164 KB
testcase_29 AC 68 ms
66,160 KB
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

ll imos[2005][2005];
ll cumsum[2005][2005];

int h, w, n, m;
int t[2005], u[2005], l[2005], r[2005];
ll a[2005];

void print();

void input(){
    cin >> h >> w >> n >> m;
    for(int i = 0; i < n; i++) {
        cin >> t[i] >> u[i] >> l[i] >> r[i] >> a[i];
    }
    for(int i = 0; i < m; i++){
        int x, y, b, c; cin >> x >> y >> b >> c;
        int x1 = max(0, x-b);
        int x2 = min(h, x+b);
        int y1 = max(0, y-b);
        int y2 = min(w, y+b);
        imos[x1][y1]+=c;
        imos[x1][y2+1]-=c;
        imos[x2+1][y1]-=c;
        imos[x2+1][y2+1]+=c;
    }
    for(int i = 1; i <= h; i++){
        for(int j = 0; j <= w; j++) imos[i][j] += imos[i-1][j];
    }
    for(int i = 0; i <= h; i++){
        for(int j = 1; j <= w; j++) imos[i][j] += imos[i][j-1];
    }
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++) {
            cumsum[i][j] = cumsum[i][j-1]+cumsum[i-1][j]-cumsum[i-1][j-1]+imos[i][j];
        }
    }
}

ll calc(int t, int u, int l, int r){
    return cumsum[u][r]-cumsum[u][l-1]-cumsum[t-1][r]+cumsum[t-1][l-1];
}

void print(){
    for(int i = 0; i <= h; i++){
        for(int j = 0; j <= w; j++){
            cout << imos[i][j] << ' ';
        }
        cout << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    input();
    int ans = 0;
    for(int i = 0; i < n; i++){
        ll x = calc(t[i], u[i], l[i], r[i]);
        if(x < a[i]) ans++;
    }
    cout << ans << endl;
}
0