結果

問題 No.1490 スライムと爆弾
ユーザー m_tsubasam_tsubasa
提出日時 2021-04-23 22:32:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,460 bytes
コンパイル時間 2,197 ms
コンパイル使用メモリ 209,276 KB
実行使用メモリ 38,672 KB
最終ジャッジ日時 2023-09-17 12:39:16
合計ジャッジ時間 5,935 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 136 ms
34,384 KB
testcase_29 AC 137 ms
34,380 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

struct slime {
  long long t, u, l, r, a;
  slime(long long _t = 0, long long _u = 0, long long _l = 0, long long _r = 0,
        long long _a = 0)
      : t(_t), u(_u), l(_l), r(_r), a(_a) {}
};

long long h, w, n, m;
vector<slime> v;
vector<vector<long long>> sum;

int solve();

int main() {
  cin >> h >> w >> n >> m;
  v.resize(n);
  for (auto &[t, u, l, r, a] : v)
    cin >> t >> u >> l >> r >> a, --t, --l, --u, --r;
  sum.assign(h + 1, vector<long long>(w + 1, 0));
  for (int i = 0; i < m; ++i) {
    long long x, y, b, c, t, u, l, r;
    cin >> x >> y >> b >> c, --x, --y;
    t = max(0LL, x - b), u = min(h, x + b + 1);
    l = max(0LL, y - b), r = min(w, y + b + 1);
    sum[t][l] += c, sum[t][r] -= c, sum[u][l] -= c, sum[u][r] += c;
  }
  cout << solve() << endl;
  return 0;
}

int solve() {
  int res = 0;
  for (int i = 0; i <= h; ++i)
    for (int j = 1; j <= w; ++j) sum[i][j] += sum[i][j - 1];
  for (int i = 1; i <= h; ++i)
    for (int j = 0; j <= w; ++j) sum[i][j] += sum[i - 1][j];
  for (int i = 0; i <= h; ++i)
    for (int j = 0; j <= w; ++j) {
      if (j) sum[i][j] += sum[i][j - 1];
      if (i) sum[i][j] += sum[i - 1][j];
      if (i && j) sum[i][j] -= sum[i - 1][j - 1];
    }

  for (auto [t, u, l, r, a] : v) {
    long long now = sum[u][r];
    if (t) now -= sum[t][r];
    if (l) now -= sum[u][l];
    if (t && l) now += sum[t][l];
    if (now < a) ++res;
  }
  return res;
}
0