結果
| 問題 |
No.1490 スライムと爆弾
|
| コンテスト | |
| ユーザー |
t33f
|
| 提出日時 | 2021-04-23 22:33:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 324 ms / 2,000 ms |
| コード長 | 1,314 bytes |
| コンパイル時間 | 842 ms |
| コンパイル使用メモリ | 81,292 KB |
| 最終ジャッジ日時 | 2025-01-21 00:10:50 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <tuple>
#include <vector>
#include <iostream>
using namespace std;
int main() {
int h, w, n, m; cin >> h >> w >> n >> m;
vector sum(h+1, vector<long long>(w+1, 0));
vector<tuple<int, int, int, int, int> > queries;
for (int i = 0; i < n; i++) {
int x1, x2, y1, y2, a; cin >> x1 >> x2 >> y1 >> y2 >> a;
queries.emplace_back(x1-1, x2-1, y1-1, y2-1, a);
}
for (int i = 0; i < m; i++) {
int x, y, b, c; cin >> x >> y >> b >> c;
const int x1 = max(0, x - 1 - b), x2 = min(h, x + b),
y1 = max(0, y - 1 - b), y2 = min(w, y + b);
sum[x1][y1] += c;
sum[x1][y2] -= c;
sum[x2][y1] -= c;
sum[x2][y2] += c;
}
for (int t = 0; t < 2; t++) {
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (i > 0) sum[i][j] += sum[i-1][j];
if (j > 0) sum[i][j] += sum[i][j-1];
if (i > 0 && j > 0) sum[i][j] -= sum[i-1][j-1];
}
}
}
int ans = n;
for (auto [x1, x2, y1, y2, a] : queries) {
long long s = sum[x2][y2];
if (x1 > 0) s -= sum[x1-1][y2];
if (y1 > 0) s -= sum[x2][y1-1];
if (x1 > 0 && y1 > 0) s += sum[x1-1][y1-1];
if (s >= a) ans--;
}
cout << ans << endl;
}
t33f