結果

問題 No.1490 スライムと爆弾
ユーザー chocoruskchocorusk
提出日時 2021-04-23 22:03:27
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 283 ms / 2,000 ms
コード長 1,750 bytes
コンパイル時間 3,322 ms
コンパイル使用メモリ 187,824 KB
実行使用メモリ 68,956 KB
最終ジャッジ日時 2023-09-17 12:16:05
合計ジャッジ時間 7,937 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,544 KB
testcase_01 AC 2 ms
5,500 KB
testcase_02 AC 3 ms
7,968 KB
testcase_03 AC 3 ms
7,740 KB
testcase_04 AC 3 ms
7,924 KB
testcase_05 AC 3 ms
8,000 KB
testcase_06 AC 3 ms
5,624 KB
testcase_07 AC 3 ms
7,776 KB
testcase_08 AC 3 ms
7,900 KB
testcase_09 AC 2 ms
5,688 KB
testcase_10 AC 2 ms
5,512 KB
testcase_11 AC 3 ms
5,544 KB
testcase_12 AC 2 ms
5,612 KB
testcase_13 AC 122 ms
46,884 KB
testcase_14 AC 144 ms
54,344 KB
testcase_15 AC 87 ms
53,824 KB
testcase_16 AC 111 ms
37,936 KB
testcase_17 AC 55 ms
42,980 KB
testcase_18 AC 142 ms
48,148 KB
testcase_19 AC 147 ms
58,660 KB
testcase_20 AC 111 ms
55,892 KB
testcase_21 AC 73 ms
55,096 KB
testcase_22 AC 134 ms
44,724 KB
testcase_23 AC 2 ms
5,548 KB
testcase_24 AC 2 ms
5,500 KB
testcase_25 AC 229 ms
68,820 KB
testcase_26 AC 230 ms
68,768 KB
testcase_27 AC 229 ms
68,556 KB
testcase_28 AC 148 ms
67,016 KB
testcase_29 AC 149 ms
66,908 KB
testcase_30 AC 283 ms
68,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
int h, w, n, m;
ll s[2020][2020];
ll sum[2020][2020];
int t[100010], u[100010], l[100010], r[100010], a[100010];
int main()
{
    cin>>h>>w>>n>>m;
    for(int i=0; i<n; i++){
        cin>>t[i]>>u[i]>>l[i]>>r[i]>>a[i];
        t[i]--; l[i]--;
    }
    for(int i=0; i<m; i++){
        int x, y, b, c;
        cin>>x>>y>>b>>c;
        x--; y--;
        int l1=max(0, x-b), r1=min(h, x+b+1), l2=max(0, y-b), r2=min(w, y+b+1);
        //cout<<l1<<" "<<r1<<" "<<l2<<" "<<r2<<endl;
        s[l1][l2]+=c;
        s[l1][r2]-=c;
        s[r1][l2]-=c;
        s[r1][r2]+=c;
    }
    //for(int i=0; i<h; i++) for(int j=0; j<w; j++) cout<<s[i][j]<<endl;
    for(int i=0; i<h; i++) for(int j=0; j<w; j++) s[i][j+1]+=s[i][j];
    for(int j=0; j<w; j++) for(int i=0; i<h; i++) s[i+1][j]+=s[i][j];
    for(int i=0; i<h; i++) for(int j=0; j<w; j++) sum[i+1][j+1]=sum[i+1][j]+sum[i][j+1]-sum[i][j]+s[i][j];
    int ans=0;
    for(int i=0; i<n; i++){
        //cout<<sum[u[i]][r[i]]-sum[u[i]][l[i]]-sum[t[i]][r[i]]+sum[t[i]][l[i]]<<endl;
        if(sum[u[i]][r[i]]-sum[u[i]][l[i]]-sum[t[i]][r[i]]+sum[t[i]][l[i]]<a[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}
0