結果

問題 No.1490 スライムと爆弾
ユーザー startcppstartcpp
提出日時 2021-04-23 22:09:59
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 313 ms / 2,000 ms
コード長 1,261 bytes
コンパイル時間 554 ms
コンパイル使用メモリ 69,192 KB
実行使用メモリ 41,928 KB
最終ジャッジ日時 2023-09-17 12:22:14
合計ジャッジ時間 6,268 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,536 KB
testcase_01 AC 3 ms
9,588 KB
testcase_02 AC 3 ms
9,968 KB
testcase_03 AC 3 ms
9,784 KB
testcase_04 AC 3 ms
10,020 KB
testcase_05 AC 4 ms
9,900 KB
testcase_06 AC 3 ms
9,768 KB
testcase_07 AC 4 ms
9,920 KB
testcase_08 AC 3 ms
9,892 KB
testcase_09 AC 3 ms
9,772 KB
testcase_10 AC 3 ms
9,560 KB
testcase_11 AC 3 ms
9,792 KB
testcase_12 AC 3 ms
9,740 KB
testcase_13 AC 135 ms
30,648 KB
testcase_14 AC 170 ms
35,532 KB
testcase_15 AC 99 ms
34,192 KB
testcase_16 AC 118 ms
28,448 KB
testcase_17 AC 80 ms
28,324 KB
testcase_18 AC 164 ms
31,224 KB
testcase_19 AC 156 ms
38,832 KB
testcase_20 AC 115 ms
36,060 KB
testcase_21 AC 77 ms
35,836 KB
testcase_22 AC 140 ms
30,540 KB
testcase_23 AC 3 ms
9,496 KB
testcase_24 AC 3 ms
9,536 KB
testcase_25 AC 250 ms
41,928 KB
testcase_26 AC 249 ms
41,660 KB
testcase_27 AC 248 ms
41,712 KB
testcase_28 AC 172 ms
40,184 KB
testcase_29 AC 172 ms
40,200 KB
testcase_30 AC 313 ms
41,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int h, w, n, m;
int t[100000], u[100000], l[100000], r[100000], a[100000];
int x[100000], y[100000], b[100000], c[100000];
int damage[2001][2001];

int get(int x, int y) {
	if (x < 0 || y < 0) return 0;
	return damage[x][y];
}

signed main() {
	int i, j;
	
	cin >> h >> w >> n >> m;
	rep(i, n) cin >> t[i] >> u[i] >> l[i] >> r[i] >> a[i];
	rep(i, m) cin >> x[i] >> y[i] >> b[i] >> c[i];
	rep(i, n) { t[i]--; u[i]--; l[i]--; r[i]--; }
	rep(i, m) { x[i]--; y[i]--; }
	
	rep(i, m) {
		int lx = max(x[i] - b[i], 0LL);
		int ly = max(y[i] - b[i], 0LL);
		int rx = min(x[i] + b[i] + 1, h);
		int ry = min(y[i] + b[i] + 1, w);
		damage[lx][ly] += c[i];
		damage[rx][ry] += c[i];
		damage[lx][ry] -= c[i];
		damage[rx][ly] -= c[i];
	}
	rep(i, h) rep(j, w) damage[i][j + 1] += damage[i][j];
	rep(j, w) rep(i, h) damage[i + 1][j] += damage[i][j];
	rep(i, h) rep(j, w) damage[i][j + 1] += damage[i][j];
	rep(j, w) rep(i, h) damage[i + 1][j] += damage[i][j];
	
	int ans = 0;
	rep(i, n) {
		int d = get(t[i] - 1, l[i] - 1) + get(u[i], r[i]) - get(t[i] - 1, r[i]) - get(u[i], l[i] - 1);
		if (d < a[i]) ans++;
	}
	
	cout << ans << endl;
	return 0;
}
0