結果

問題 No.1490 スライムと爆弾
ユーザー tailstails
提出日時 2023-03-09 19:40:29
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 1,382 bytes
コンパイル時間 1,039 ms
コンパイル使用メモリ 25,764 KB
実行使用メモリ 37,012 KB
最終ジャッジ日時 2023-10-18 06:24:55
合計ジャッジ時間 3,739 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
32,540 KB
testcase_01 AC 86 ms
32,540 KB
testcase_02 AC 73 ms
32,540 KB
testcase_03 AC 59 ms
32,540 KB
testcase_04 AC 55 ms
32,540 KB
testcase_05 AC 63 ms
32,540 KB
testcase_06 AC 61 ms
32,540 KB
testcase_07 AC 54 ms
32,540 KB
testcase_08 AC 69 ms
32,540 KB
testcase_09 AC 53 ms
32,540 KB
testcase_10 AC 56 ms
32,540 KB
testcase_11 AC 60 ms
32,540 KB
testcase_12 AC 60 ms
32,540 KB
testcase_13 AC 63 ms
34,528 KB
testcase_14 AC 67 ms
35,060 KB
testcase_15 AC 58 ms
33,620 KB
testcase_16 AC 62 ms
34,464 KB
testcase_17 AC 59 ms
33,320 KB
testcase_18 AC 67 ms
35,052 KB
testcase_19 AC 64 ms
34,684 KB
testcase_20 AC 60 ms
33,984 KB
testcase_21 AC 57 ms
33,256 KB
testcase_22 AC 65 ms
34,824 KB
testcase_23 AC 83 ms
32,540 KB
testcase_24 AC 82 ms
32,540 KB
testcase_25 AC 97 ms
35,320 KB
testcase_26 AC 97 ms
35,320 KB
testcase_27 AC 95 ms
35,320 KB
testcase_28 AC 59 ms
34,036 KB
testcase_29 AC 60 ms
33,980 KB
testcase_30 AC 80 ms
37,012 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:59: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
    9 | #define wt1(v) ({char wbuf[64],*wp=wbuf+sizeof wbuf;wt(v);write(1,wp,wbuf+sizeof wbuf-wp);})
      |                                                           ^~~~~
main.c:77:9: note: in expansion of macro ‘wt1’
   77 |         wt1(f3(rp,n));
      |         ^~~
main.c:78:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
   78 |         _exit(0);
      |         ^~~~~
main.c:78: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() while(*rp++>=48)
#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[2004][2004];

#define h 2000
#define w 2000

void f1(char*rp,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(){
	rep(x,2004){
		long d=0,e=0;
		rep(y,2004){
			f[x][y]=d+=e+=f[x][y];
		}
	}
	rep(y,2004){
		long d=0,e=0;
		rep(x,2004){
			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();
	rd_skip();
	rd_skip();
	long n=rd();
	rd_skip_line();
	f1(rp,n);
	f2();
	wt1(f3(rp,n));
	_exit(0);
}
0