結果
問題 | No.1490 スライムと爆弾 |
ユーザー |
![]() |
提出日時 | 2021-06-13 22:18:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 172 ms / 2,000 ms |
コード長 | 1,800 bytes |
コンパイル時間 | 2,210 ms |
コンパイル使用メモリ | 200,632 KB |
最終ジャッジ日時 | 2025-01-22 08:03:07 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:20:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | REP(i, N) scanf("%d %d %d %d %d", &T[i], &U[i], &L[i], &R[i], &A[i]), --T[i], --L[i]; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:22:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | REP(i, M) scanf("%d %d %d %d", &Y[i], &X[i], &B[i], &C[i]), --X[i], --Y[i]; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>using namespace std;#define FOR(i,a,b) for(int i=(a);i<(b);++i)#define REP(i,n) FOR(i,0,n)#define ALL(v) begin(v),end(v)template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }using ll = long long;using pii = pair<int, int>;constexpr ll INF = 1ll<<30;constexpr ll longINF = 1ll<<60;constexpr ll MOD = 1000000007;constexpr bool debug = false;//---------------------------------//int main() {int H, W, N, M;cin >> H >> W >> N >> M;vector<int> T(N), U(N), L(N), R(N), A(N);REP(i, N) scanf("%d %d %d %d %d", &T[i], &U[i], &L[i], &R[i], &A[i]), --T[i], --L[i];vector<int> X(M), Y(M), B(M), C(M);REP(i, M) scanf("%d %d %d %d", &Y[i], &X[i], &B[i], &C[i]), --X[i], --Y[i];vector imos(H + 1, vector<ll>(W + 1)); // 0-indexed 爆風ダメージREP(i, M) {const int y1 = max(0, Y[i] - B[i]);const int y2 = min(H, Y[i] + B[i] + 1); // [y1, y2)const int x1 = max(0, X[i] - B[i]);const int x2 = min(W, X[i] + B[i] + 1); // [x1, x2)imos[y1][x1] += C[i];imos[y2][x1] -= C[i];imos[y1][x2] -= C[i];imos[y2][x2] += C[i];}REP(i, H) REP(j, W) imos[i][j + 1] += imos[i][j];REP(i, H) REP(j, W) imos[i + 1][j] += imos[i][j];vector sum(H + 1, vector<ll>(W + 1)); // 1-indexed 爆風ダメージ累積和REP(i, H) REP(j, W) sum[i + 1][j + 1] = imos[i][j];REP(i, H + 1) REP(j, W) sum[i][j + 1] += sum[i][j];REP(i, H) REP(j, W + 1) sum[i + 1][j] += sum[i][j];int ans = 0;REP(i, N) {// T, U, L, Rconst ll dmg = sum[U[i]][R[i]] - sum[U[i]][L[i]] - sum[T[i]][R[i]] + sum[T[i]][L[i]];ans += dmg < A[i];}cout << ans << endl;}