結果
問題 |
No.1490 スライムと爆弾
|
ユーザー |
![]() |
提出日時 | 2021-04-24 03:27:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 110 ms / 2,000 ms |
コード長 | 1,854 bytes |
コンパイル時間 | 809 ms |
コンパイル使用メモリ | 96,172 KB |
実行使用メモリ | 36,976 KB |
最終ジャッジ日時 | 2024-07-04 08:55:43 |
合計ジャッジ時間 | 2,994 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
/* -*- coding: utf-8 -*- * * 1490.cc: No.1490 スライムと爆弾 - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ const int MAX_H = 2000; const int MAX_W = 2000; const int MAX_N = 100000; const int MAX_M = 100000; /* typedef */ typedef long long ll; struct Slime { int y0, y1, x0, x1, a; Slime() {} void read() { scanf("%d%d%d%d%d", &y0, &y1, &x0, &x1, &a); y0--, x0--; } }; /* global variables */ Slime sls[MAX_N]; ll cs[MAX_H + 2][MAX_W + 2]; /* subroutines */ /* main */ int main() { int h, w, n, m; scanf("%d%d%d%d", &h, &w, &n, &m); for (int i = 0; i < n; i++) sls[i].read(); for (int i = 0; i < m; i++) { int y, x, b, c; scanf("%d%d%d%d", &y, &x, &b, &c); int y0 = max(1, y - b), x0 = max(1, x - b); int y1 = min(h + 1, y + b + 1), x1 = min(w + 1, x + b + 1); cs[y0][x0] += c; cs[y0][x1] -= c; cs[y1][x0] -= c; cs[y1][x1] += c; } for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) cs[y + 1][x + 1] += cs[y + 1][x] + cs[y][x + 1] - cs[y][x]; for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) cs[y + 1][x + 1] += cs[y + 1][x] + cs[y][x + 1] - cs[y][x]; //for (int y = 1; y <= h; y++) //for (int x = 1; x <= w; x++) //printf("%d%c", cs[y][x], (x < w) ? ' ' : '\n'); int cnt = 0; for (int i = 0; i < n; i++) { Slime &sli = sls[i]; ll sum = cs[sli.y1][sli.x1] - cs[sli.y1][sli.x0] - cs[sli.y0][sli.x1] + cs[sli.y0][sli.x0]; if (sli.a > sum) cnt++; } printf("%d\n", cnt); return 0; }