結果

問題 No.1490 スライムと爆弾
ユーザー kwm_tkwm_t
提出日時 2021-04-30 14:47:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 1,859 bytes
コンパイル時間 1,810 ms
コンパイル使用メモリ 167,692 KB
実行使用メモリ 69,712 KB
最終ジャッジ日時 2023-09-25 15:15:22
合計ジャッジ時間 6,171 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,416 KB
testcase_01 AC 2 ms
5,604 KB
testcase_02 AC 3 ms
7,944 KB
testcase_03 AC 2 ms
5,936 KB
testcase_04 AC 3 ms
5,892 KB
testcase_05 AC 3 ms
5,860 KB
testcase_06 AC 2 ms
5,776 KB
testcase_07 AC 2 ms
5,664 KB
testcase_08 AC 3 ms
5,816 KB
testcase_09 AC 2 ms
5,684 KB
testcase_10 AC 2 ms
5,468 KB
testcase_11 AC 2 ms
5,580 KB
testcase_12 AC 2 ms
5,792 KB
testcase_13 AC 67 ms
44,052 KB
testcase_14 AC 85 ms
54,000 KB
testcase_15 AC 58 ms
53,772 KB
testcase_16 AC 55 ms
39,976 KB
testcase_17 AC 42 ms
41,024 KB
testcase_18 AC 80 ms
48,812 KB
testcase_19 AC 84 ms
59,472 KB
testcase_20 AC 64 ms
56,464 KB
testcase_21 AC 50 ms
53,460 KB
testcase_22 AC 68 ms
47,172 KB
testcase_23 AC 2 ms
5,468 KB
testcase_24 AC 2 ms
5,396 KB
testcase_25 AC 139 ms
69,712 KB
testcase_26 AC 136 ms
69,664 KB
testcase_27 AC 137 ms
69,608 KB
testcase_28 AC 98 ms
66,004 KB
testcase_29 AC 101 ms
65,980 KB
testcase_30 AC 155 ms
69,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
long long imos[2002][2002];
long long sum[2002][2002];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int h, w, n, m; cin >> h >> w >> n >> m;
	vector<long long>t(n), u(n), l(n), r(n), a(n);
	rep(i, n) {
		cin >> t[i] >> u[i] >> l[i] >> r[i] >> a[i];
		t[i]--; u[i]--; l[i]--; r[i]--;
	}
	rep(i, m) {
		int x, y, b, c; cin >> x >> y >> b >> c;
		imos[max(1, x - b)][max(1, y - b)] += c;
		imos[min(h + 1, x + b + 1)][min(w + 1, y + b + 1)] += c;
		imos[max(1, x - b)][min(w + 1, y + b + 1)] -= c;
		imos[min(h + 1, x + b + 1)][max(1, y - b)] -= c;
	}
	rep(i, h + 1) {
		rep(j, w) {
			imos[i][j + 1] += imos[i][j];
		}
	}
	rep(i, w + 1) {
		rep(j, h) {
			imos[j + 1][i] += imos[j][i];
		}
	}
	rep2(i, 1, h + 1) {
		rep2(j, 1, w + 1) {
			sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + imos[i][j];
		}
	}
	/*if (false) {
		rep(i, h + 2) {
			rep(j, w + 2) {
				cout << imos[i][j] << " ";
			}
			cout << endl;
		}
		cout << endl;
		rep(i, h + 1) {
			rep(j, w + 1) {
				cout << sum[i][j] << " ";
			}
			cout << endl;
		}
	}*/
	int ans = 0;
	rep(i, n) {
		//[i,j) = s[j+1] - s[i];
		long long att = sum[u[i] + 1][r[i] + 1] - sum[u[i] + 1][l[i]] - sum[t[i]][r[i] + 1] + sum[t[i]][l[i]];
		a[i] -= att;
		if (a[i] > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}
0