結果
| 問題 | 
                            No.1490 スライムと爆弾
                             | 
                    
| コンテスト | |
| ユーザー | 
                             たたき@競プロ
                         | 
                    
| 提出日時 | 2023-09-04 03:32:58 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 344 ms / 2,000 ms | 
| コード長 | 1,245 bytes | 
| コンパイル時間 | 5,499 ms | 
| コンパイル使用メモリ | 313,488 KB | 
| 実行使用メモリ | 73,088 KB | 
| 最終ジャッジ日時 | 2024-06-22 03:15:02 | 
| 合計ジャッジ時間 | 9,935 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 28 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353; //1000000007;
using ll=long long;
using pp=pair<int,int>;
#define sr string 
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
  int h,w,n,m;cin>>h>>w>>n>>m;
  vc sl(n,vc<ll>(5)); rep(i,n)rep(j,5)cin>>sl[i][j];
  vc v(h,vc<ll>(w,0));
  rep(z,m){
    int x,y,b,c;cin>>x>>y>>b>>c;
    x--;y--;
    int nx=x-b,ny=y-b;
    nx=max(nx,0); ny=max(ny,0);
    v[nx][ny]+=c;
    ny=y+b+1;
    if(ny<w)v[nx][ny]-=c;
    nx=x+b+1; if(nx>=h)continue;
    ny=y-b; ny=max(ny,0);
    v[nx][ny]-=c;
    ny=y+b+1;
    if(ny<w)v[nx][ny]+=c;
  }
 
  rep(i,h)rep(j,w-1)v[i][j+1]+=v[i][j];
  rep(i,h-1)rep(j,w)v[i+1][j]+=v[i][j];
  vc vs(h+1,vc<ll>(w+1,0));
  rep(i,h)rep(j,w)vs[i+1][j+1]=v[i][j];
  rep(i,h+1)rep(j,w)vs[i][j+1]+=vs[i][j];
  rep(i,h)rep(j,w+1)vs[i+1][j]+=vs[i][j];
  int ans=0;
  rep(i,n){
    auto t=sl[i];
    ll a=t[0],b=t[1],c=t[2],d=t[3],h=t[4];
    a--;c--;
    h-=vs[b][d]-vs[a][d]-vs[b][c]+vs[a][c];
    if(h>0)ans++;
  }
  cout<<ans<<"\n";
 
}
            
            
            
        
            
たたき@競プロ