結果

問題 No.1490 スライムと爆弾
ユーザー tnakao0123tnakao0123
提出日時 2021-04-24 03:27:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 1,854 bytes
コンパイル時間 796 ms
コンパイル使用メモリ 92,008 KB
実行使用メモリ 37,024 KB
最終ジャッジ日時 2023-09-17 13:23:06
合計ジャッジ時間 3,311 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,568 KB
testcase_01 AC 2 ms
5,572 KB
testcase_02 AC 3 ms
6,080 KB
testcase_03 AC 3 ms
5,888 KB
testcase_04 AC 2 ms
6,024 KB
testcase_05 AC 3 ms
5,932 KB
testcase_06 AC 3 ms
5,772 KB
testcase_07 AC 3 ms
5,768 KB
testcase_08 AC 2 ms
5,912 KB
testcase_09 AC 2 ms
5,828 KB
testcase_10 AC 2 ms
5,756 KB
testcase_11 AC 2 ms
5,644 KB
testcase_12 AC 3 ms
5,720 KB
testcase_13 AC 51 ms
25,884 KB
testcase_14 AC 58 ms
30,384 KB
testcase_15 AC 35 ms
29,884 KB
testcase_16 AC 43 ms
23,496 KB
testcase_17 AC 27 ms
24,016 KB
testcase_18 AC 57 ms
26,268 KB
testcase_19 AC 53 ms
33,984 KB
testcase_20 AC 41 ms
31,692 KB
testcase_21 AC 26 ms
31,836 KB
testcase_22 AC 51 ms
25,684 KB
testcase_23 AC 2 ms
5,524 KB
testcase_24 AC 2 ms
5,708 KB
testcase_25 AC 90 ms
36,856 KB
testcase_26 AC 89 ms
36,704 KB
testcase_27 AC 88 ms
36,868 KB
testcase_28 AC 59 ms
36,264 KB
testcase_29 AC 62 ms
36,232 KB
testcase_30 AC 112 ms
37,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- 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;
}
0