結果

問題 No.1490 スライムと爆弾
ユーザー tailstails
提出日時 2023-03-09 19:21:10
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,343 bytes
コンパイル時間 806 ms
コンパイル使用メモリ 26,324 KB
実行使用メモリ 36,960 KB
最終ジャッジ日時 2023-10-18 06:24:40
合計ジャッジ時間 5,795 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 0 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 0 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 28 ms
24,288 KB
testcase_14 AC 41 ms
26,892 KB
testcase_15 AC 29 ms
27,416 KB
testcase_16 AC 19 ms
20,000 KB
testcase_17 AC 26 ms
21,056 KB
testcase_18 AC 37 ms
24,836 KB
testcase_19 AC 38 ms
30,524 KB
testcase_20 AC 31 ms
29,756 KB
testcase_21 AC 26 ms
29,028 KB
testcase_22 AC 27 ms
24,452 KB
testcase_23 AC 0 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 92 ms
35,252 KB
testcase_26 AC 92 ms
35,252 KB
testcase_27 AC 90 ms
35,252 KB
testcase_28 AC 57 ms
33,984 KB
testcase_29 AC 59 ms
33,928 KB
testcase_30 AC 77 ms
36,960 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:59: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
    8 | #define wt1(v) ({char wbuf[64],*wp=wbuf+sizeof wbuf;wt(v);write(1,wp,wbuf+sizeof wbuf-wp);})
      |                                                           ^~~~~
main.c:71:9: note: in expansion of macro ‘wt1’
   71 |         wt1(f3(rp,n));
      |         ^~~
main.c:72:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
   72 |         _exit(0);
      |         ^~~~~
main.c:72:9: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd_skip_line() while(*rp++!=10)
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define wt(v) ({unsigned _z=v;do*--wp=_z%10+48;while(_z/=10);})
#define wt1(v) ({char wbuf[64],*wp=wbuf+sizeof wbuf;wt(v);write(1,wp,wbuf+sizeof wbuf-wp);})
#define rep(v,e) for(typeof(e) v=0;v<e;++v)
#define min(a,b) (a<=b?a:b)
#define max(a,b) (a>=b?a:b)

typedef unsigned long ulong;

long f[2002][2002];

void f1(char*rp,long h,long w,long n){
	rep(i,n)rd_skip_line();
	while(*rp){
		long x=rd();
		long y=rd();
		long b=rd();
		long c=rd();
		long x0=max(0,x-b);
		long x1=min(h,x+b)+1;
		long y0=max(0,y-b);
		long y1=min(w,y+b)+1;
		f[x0][y0]+=c;
		f[x0][y1]-=c;
		f[x1][y0]-=c;
		f[x1][y1]+=c;
	}
}

void f2(long h,long w){
	rep(x,h+1){
		long d=0,e=0;
		rep(y,w+1){
			f[x][y]=d+=e+=f[x][y];
		}
	}
	rep(y,w+1){
		long d=0,e=0;
		rep(x,h+1){
			f[x][y]=d+=e+=f[x][y];
		}
	}
}

long f3(char*rp,long n){
	long z=0;
	rep(i,n){
		long t=rd()-1;
		long u=rd();
		long l=rd()-1;
		long r=rd();
		long a=rd();
		z+=a>f[t][l]-f[t][r]-f[u][l]+f[u][r];
	}
	return z;
}

int main(){
	rd_init();
	long h=rd();
	long w=rd();
	long n=rd();
	rd_skip_line();
	f1(rp,h,w,n);
	f2(h,w);
	wt1(f3(rp,n));
	_exit(0);
}
0