結果

問題 No.1490 スライムと爆弾
ユーザー 👑 Nachia
提出日時 2021-04-23 21:33:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 1,099 bytes
コンパイル時間 1,001 ms
コンパイル使用メモリ 77,360 KB
最終ジャッジ日時 2025-01-20 23:37:32
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |   scanf("%d%d",&H,&W);
      |   ~~~~~^~~~~~~~~~~~~~
main.cpp:18:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |   scanf("%d%d",&N,&M);
      |   ~~~~~^~~~~~~~~~~~~~
main.cpp:21:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |     int l,t,r,b,a; scanf("%d%d%d%d%d",&t,&b,&l,&r,&a); l--; t--;
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:25:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |     int x,y,w,a; scanf("%d%d%d%d",&x,&y,&w,&a); x--; y--;
      |                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)

struct Slime{ int l,t,r,b,a; };

int H,W;
int N,M;

vector<Slime> A;
ll X[2002][2002] = {};

int main(){
  scanf("%d%d",&H,&W);
  scanf("%d%d",&N,&M);
  A.resize(N);
  rep(i,N){
    int l,t,r,b,a; scanf("%d%d%d%d%d",&t,&b,&l,&r,&a); l--; t--;
    A[i] = {l,t,r,b,a};
  }
  rep(i,M){
    int x,y,w,a; scanf("%d%d%d%d",&x,&y,&w,&a); x--; y--;
    int l = max(0,x-w);
    int r = min(H,x+1+w);
    int t = max(0,y-w);
    int b = min(W,y+1+w);
    X[l+1][t+1] += a;
    X[l+1][b+1] -= a;
    X[r+1][t+1] -= a;
    X[r+1][b+1] += a;
  }
  rep(i,2001) rep(j,2002) X[i+1][j] += X[i][j];
  rep(i,2002) rep(j,2001) X[i][j+1] += X[i][j];
  rep(i,2001) rep(j,2002) X[i+1][j] += X[i][j];
  rep(i,2002) rep(j,2001) X[i][j+1] += X[i][j];
  int ans = 0;
  for(auto s : A){
    ll damage = 0;
    damage += X[s.b][s.r];
    damage -= X[s.b][s.l];
    damage -= X[s.t][s.r];
    damage += X[s.t][s.l];
    if(damage < s.a) ans++;
  }
  printf("%d\n",ans);
  return 0;
}
0