結果

問題 No.1490 スライムと爆弾
ユーザー kwm_tkwm_t
提出日時 2021-04-25 01:41:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 1,945 bytes
コンパイル時間 1,649 ms
コンパイル使用メモリ 167,912 KB
実行使用メモリ 69,732 KB
最終ジャッジ日時 2023-09-17 13:57:50
合計ジャッジ時間 4,731 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,452 KB
testcase_01 AC 2 ms
5,448 KB
testcase_02 AC 4 ms
7,920 KB
testcase_03 AC 3 ms
5,740 KB
testcase_04 AC 3 ms
5,776 KB
testcase_05 AC 3 ms
5,788 KB
testcase_06 AC 2 ms
5,672 KB
testcase_07 AC 2 ms
5,668 KB
testcase_08 AC 3 ms
5,736 KB
testcase_09 AC 2 ms
5,608 KB
testcase_10 AC 2 ms
5,492 KB
testcase_11 AC 3 ms
5,484 KB
testcase_12 AC 2 ms
5,612 KB
testcase_13 AC 67 ms
44,096 KB
testcase_14 AC 87 ms
54,116 KB
testcase_15 AC 60 ms
53,660 KB
testcase_16 AC 55 ms
40,000 KB
testcase_17 AC 41 ms
41,124 KB
testcase_18 AC 80 ms
49,216 KB
testcase_19 AC 87 ms
59,332 KB
testcase_20 AC 68 ms
56,528 KB
testcase_21 AC 50 ms
53,432 KB
testcase_22 AC 67 ms
47,240 KB
testcase_23 AC 2 ms
5,488 KB
testcase_24 AC 2 ms
5,544 KB
testcase_25 AC 150 ms
69,588 KB
testcase_26 AC 152 ms
69,656 KB
testcase_27 AC 152 ms
69,676 KB
testcase_28 AC 100 ms
66,008 KB
testcase_29 AC 101 ms
65,988 KB
testcase_30 AC 154 ms
69,732 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];
	}
	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;
	}
	if (false) {
		rep(i, h + 2) {
			rep(j, w + 2) {
				cout << imos[i][j] << " ";
			}
			cout << endl;
		}
		cout << endl;
	}
	rep2(i, 1, h + 1) {
		rep2(j, 1, w + 1) {
			imos[i][j + 1] += imos[i][j];
		}
	}
	rep2(i, 1, w + 1) {
		rep2(j, 1, h + 1) {
			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) {
		long long att = sum[u[i]][r[i]] - sum[u[i]][l[i] - 1] - sum[t[i] - 1][r[i]] + sum[t[i] - 1][l[i] - 1];
		a[i] -= att;
		if (a[i] > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}
0