結果

問題 No.1490 スライムと爆弾
ユーザー simansiman
提出日時 2022-06-29 00:19:32
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,820 bytes
コンパイル時間 4,206 ms
コンパイル使用メモリ 106,104 KB
実行使用メモリ 39,408 KB
最終ジャッジ日時 2023-08-14 01:38:28
合計ジャッジ時間 11,244 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
35,028 KB
testcase_01 AC 10 ms
35,096 KB
testcase_02 AC 8 ms
35,096 KB
testcase_03 AC 10 ms
34,960 KB
testcase_04 AC 10 ms
35,048 KB
testcase_05 AC 9 ms
35,132 KB
testcase_06 AC 9 ms
35,012 KB
testcase_07 AC 9 ms
34,968 KB
testcase_08 AC 10 ms
35,128 KB
testcase_09 AC 10 ms
34,964 KB
testcase_10 AC 10 ms
35,024 KB
testcase_11 AC 11 ms
35,024 KB
testcase_12 AC 10 ms
35,028 KB
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 9 ms
35,096 KB
testcase_24 AC 8 ms
35,024 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 182 ms
36,892 KB
testcase_29 AC 180 ms
37,008 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;
ll S[2010][2010];

int main() {
  int H, W, N, M;
  cin >> H >> W >> N >> M;

  int T[N];
  int U[N];
  int L[N];
  int R[N];
  ll A[N];

  for (int i = 0; i < N; ++i) {
    cin >> T[i] >> U[i] >> L[i] >> R[i] >> A[i];
  }

  int X[M];
  int Y[M];
  int B[M];
  ll C[M];

  for (int i = 0; i < M; ++i) {
    cin >> X[i] >> Y[i] >> B[i] >> C[i];
  }

  memset(S, 0, sizeof(S));
  for (int i = 0; i < M; ++i) {
    int y = Y[i];
    int x = X[i];
    int b = B[i];
    ll c = C[i];
    int ly = max(1, y - b);
    int lx = max(1, x - b);
    int ry = min(H, y + b);
    int rx = min(W, x + b);

    // fprintf(stderr, "(%d, %d) - (%d, %d)\n", ly, lx, ry, rx);
    S[ly][lx] += c;
    S[ly][rx + 1] -= c;
    S[ry + 1][lx] -= c;
    S[ry + 1][rx + 1] += c;
  }

  for (int i = 0; i < 2; ++i) {
    for (int y = 0; y <= H; ++y) {
      ll sum = 0;
      for (int x = 0; x <= W; ++x) {
        sum += S[y][x];
        S[y][x] = sum;
      }
    }

    for (int x = 0; x <= W; ++x) {
      ll sum = 0;
      for (int y = 0; y <= H; ++y) {
        sum += S[y][x];
        S[y][x] = sum;
      }
    }
  }

  /*
  for (int y = 0; y <= H; ++y) {
    for (int x = 0; x <= W; ++x) {
      cerr << S[y][x] << " ";
    }
    cerr << endl;
  }
  */

  int ans = 0;

  for (int i = 0; i < N; ++i) {
    int ly = T[i];
    int ry = U[i];
    int lx = L[i];
    int rx = R[i];
    // fprintf(stderr, "(%d, %d) - (%d, %d)\n", ly, lx, ry, rx);
    ll damage = S[ry][rx] - S[ry][lx - 1] - S[ly - 1][rx] + S[ly - 1][lx - 1];
    if (damage < A[i]) ++ans;
  }

  cout << ans << endl;

  return 0;
}
0