結果

問題 No.1490 スライムと爆弾
ユーザー 👑 kmjpkmjp
提出日時 2021-04-24 02:36:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 1,573 bytes
コンパイル時間 1,967 ms
コンパイル使用メモリ 201,412 KB
実行使用メモリ 38,668 KB
最終ジャッジ日時 2023-09-17 13:21:43
合計ジャッジ時間 4,654 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,524 KB
testcase_01 AC 3 ms
7,488 KB
testcase_02 AC 5 ms
16,228 KB
testcase_03 AC 7 ms
32,384 KB
testcase_04 AC 8 ms
30,356 KB
testcase_05 AC 6 ms
26,372 KB
testcase_06 AC 8 ms
32,288 KB
testcase_07 AC 8 ms
34,448 KB
testcase_08 AC 6 ms
22,296 KB
testcase_09 AC 8 ms
36,388 KB
testcase_10 AC 7 ms
32,236 KB
testcase_11 AC 7 ms
30,220 KB
testcase_12 AC 7 ms
30,216 KB
testcase_13 AC 56 ms
38,300 KB
testcase_14 AC 63 ms
38,668 KB
testcase_15 AC 40 ms
38,272 KB
testcase_16 AC 49 ms
38,444 KB
testcase_17 AC 36 ms
38,468 KB
testcase_18 AC 64 ms
38,500 KB
testcase_19 AC 58 ms
38,476 KB
testcase_20 AC 46 ms
38,484 KB
testcase_21 AC 32 ms
38,308 KB
testcase_22 AC 55 ms
38,492 KB
testcase_23 AC 3 ms
7,544 KB
testcase_24 AC 3 ms
7,644 KB
testcase_25 AC 101 ms
38,632 KB
testcase_26 AC 99 ms
38,524 KB
testcase_27 AC 97 ms
38,600 KB
testcase_28 AC 66 ms
38,256 KB
testcase_29 AC 68 ms
38,372 KB
testcase_30 AC 117 ms
38,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int H,W,N,M;
int T[202020],U[202020],L[202020],R[202020],A[202020];
ll S[2020][2020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W>>N>>M;
	FOR(i,N) {
		cin>>T[i]>>U[i]>>L[i]>>R[i]>>A[i];
	}
	FOR(i,M) {
		int b;
		cin>>y>>x>>b>>r;
		S[max(1,y-b)][max(1,x-b)]+=r;
		S[min(2010,y+b+1)][max(1,x-b)]-=r;
		S[max(1,y-b)][min(2010,x+b+1)]-=r;
		S[min(2010,y+b+1)][min(2010,x+b+1)]+=r;
	}
	FOR(y,H+2) FOR(x,W+2) {
		if(y) S[y][x]+=S[y-1][x];
		if(x) S[y][x]+=S[y][x-1];
		if(y&&x) S[y][x]-=S[y-1][x-1];
	}
	FOR(y,H+2) FOR(x,W+2) {
		if(y) S[y][x]+=S[y-1][x];
		if(x) S[y][x]+=S[y][x-1];
		if(y&&x) S[y][x]-=S[y-1][x-1];
	}
	
	int ret=0;
	FOR(i,N) {
		ll d=S[U[i]][R[i]]-S[T[i]-1][R[i]]-S[U[i]][L[i]-1]+S[T[i]-1][L[i]-1];
		if(d<A[i]) ret++;
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0