結果

問題 No.697 池の数はいくつか
ユーザー tailstails
提出日時 2021-07-02 16:05:21
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 93 ms / 6,000 ms
コード長 789 bytes
コンパイル時間 1,002 ms
コンパイル使用メモリ 32,128 KB
実行使用メモリ 56,452 KB
最終ジャッジ日時 2024-04-25 21:04:17
合計ジャッジ時間 3,441 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 1 ms
6,944 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 0 ms
6,944 KB
testcase_24 AC 11 ms
6,940 KB
testcase_25 AC 11 ms
6,944 KB
testcase_26 AC 11 ms
6,944 KB
testcase_27 AC 10 ms
6,940 KB
testcase_28 AC 11 ms
6,940 KB
testcase_29 AC 67 ms
56,404 KB
testcase_30 AC 93 ms
19,940 KB
testcase_31 AC 67 ms
56,452 KB
testcase_32 AC 88 ms
19,936 KB
testcase_33 AC 87 ms
19,808 KB
testcase_34 AC 89 ms
21,984 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:12:1: warning: return type defaults to 'int' [-Wimplicit-int]
   12 | main(){
      | ^~~~
main.c: In function 'main':
main.c:14:9: warning: implicit declaration of function 'read' [-Wimplicit-function-declaration]
   14 |         read(0,rp,sizeof rbuf-8192);
      |         ^~~~
main.c:38:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   38 |         write(1,wp,wbuf+sizeof wbuf-wp);
      |         ^~~~~
main.c:39:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   39 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

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

char rbuf[1<<25];

#define rd(v) long v=0;{int _c;while(_c=*rp-48,*rp++=0,_c>=0)v=v*10+_c;}
#define wt(v) {long _z=v;do*--wp=_z%10+48;while(_z/=10);}
#define rep(v,e) for(long v=0;v<e;++v)

int q[10<<20];

main(){
	char*rp=rbuf+8192;
	read(0,rp,sizeof rbuf-8192);
	rd(h);
	rd(w);
	long res=0;
	long n=h*w;
	rep(x,n){
		if(rp[x<<1]&1){
			++res;
			int i=0;
			q[i++]=x;
			while(i){
				long z=q[--i];
				if(rp[z<<1]&1){
					rp[z<<1]=0;
					if(rp[z+w<<1]&1) q[i++]=z+w;
					if(rp[z+1<<1]&1 && rp[z+0<<1|1]!='\n') q[i++]=z+1;
					if(rp[z-1<<1]&1 && rp[z-1<<1|1]!='\n') q[i++]=z-1;
					if(rp[z-w<<1]&1) q[i++]=z-w;
				}
			}
		}
	}
	char wbuf[64],*wp=wbuf+sizeof wbuf;
	wt(res);
	write(1,wp,wbuf+sizeof wbuf-wp);
	_exit(0);
}
0