結果

問題 No.1490 スライムと爆弾
ユーザー tkmst201tkmst201
提出日時 2021-06-13 22:18:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 1,800 bytes
コンパイル時間 2,030 ms
コンパイル使用メモリ 205,988 KB
実行使用メモリ 69,388 KB
最終ジャッジ日時 2023-08-25 01:32:15
合計ジャッジ時間 7,532 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 63 ms
32,220 KB
testcase_14 AC 76 ms
40,616 KB
testcase_15 AC 48 ms
34,340 KB
testcase_16 AC 50 ms
22,328 KB
testcase_17 AC 48 ms
39,216 KB
testcase_18 AC 79 ms
40,480 KB
testcase_19 AC 70 ms
37,580 KB
testcase_20 AC 52 ms
31,544 KB
testcase_21 AC 40 ms
30,284 KB
testcase_22 AC 59 ms
25,612 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 109 ms
67,860 KB
testcase_26 AC 110 ms
67,776 KB
testcase_27 AC 108 ms
67,780 KB
testcase_28 AC 97 ms
67,312 KB
testcase_29 AC 97 ms
67,188 KB
testcase_30 AC 143 ms
69,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

int main() {
	int H, W, N, M;
	cin >> H >> W >> N >> M;
	vector<int> T(N), U(N), L(N), R(N), A(N);
	REP(i, N) scanf("%d %d %d %d %d", &T[i], &U[i], &L[i], &R[i], &A[i]), --T[i], --L[i];
	vector<int> X(M), Y(M), B(M), C(M);
	REP(i, M) scanf("%d %d %d %d", &Y[i], &X[i], &B[i], &C[i]), --X[i], --Y[i];
	
	vector imos(H + 1, vector<ll>(W + 1)); // 0-indexed 爆風ダメージ
	REP(i, M) {
		const int y1 = max(0, Y[i] - B[i]);
		const int y2 = min(H, Y[i] + B[i] + 1); // [y1, y2)
		const int x1 = max(0, X[i] - B[i]);
		const int x2 = min(W, X[i] + B[i] + 1); // [x1, x2)
		imos[y1][x1] += C[i];
		imos[y2][x1] -= C[i];
		imos[y1][x2] -= C[i];
		imos[y2][x2] += C[i];
	}
	REP(i, H) REP(j, W) imos[i][j + 1] += imos[i][j];
	REP(i, H) REP(j, W) imos[i + 1][j] += imos[i][j];
	
	vector sum(H + 1, vector<ll>(W + 1)); // 1-indexed 爆風ダメージ累積和
	REP(i, H) REP(j, W) sum[i + 1][j + 1] = imos[i][j];
	REP(i, H + 1) REP(j, W) sum[i][j + 1] += sum[i][j];
	REP(i, H) REP(j, W + 1) sum[i + 1][j] += sum[i][j];
	
	int ans = 0;
	REP(i, N) {
		// T, U, L, R
		const ll dmg = sum[U[i]][R[i]] - sum[U[i]][L[i]] - sum[T[i]][R[i]] + sum[T[i]][L[i]];
		ans += dmg < A[i];
	}
	cout << ans << endl;
}
0