結果

問題 No.697 池の数はいくつか
ユーザー 👑 tails
提出日時 2018-06-09 18:13:36
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 393 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 83 ms
コンパイル使用メモリ 25,140 KB
最終ジャッジ日時 2026-02-22 01:11:29
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c:2:1: warning: data definition has no type or storage class
    2 | h,w;r;
      | ^
main.c:2:1: error: type defaults to 'int' in declaration of 'h' [-Wimplicit-int]
main.c:2:3: error: type defaults to 'int' in declaration of 'w' [-Wimplicit-int]
    2 | h,w;r;
      |   ^
main.c:2:5: warning: data definition has no type or storage class
    2 | h,w;r;
      |     ^
main.c:2:5: error: type defaults to 'int' in declaration of 'r' [-Wimplicit-int]
main.c:3:1: error: return type defaults to 'int' [-Wimplicit-int]
    3 | f(y,x,l,r){
      | ^
main.c: In function 'f':
main.c:3:1: warning: old-style function definition [-Wold-style-definition]
main.c:3:1: error: type of 'y' defaults to 'int' [-Wimplicit-int]
main.c:3:1: error: type of 'x' defaults to 'int' [-Wimplicit-int]
main.c:3:1: error: type of 'l' defaults to 'int' [-Wimplicit-int]
main.c:3:1: error: type of 'r' defaults to 'int' [-Wimplicit-int]
main.c: At top level:
main.c:12:1: error: return type defaults to 'int' [-Wimplicit-int]
   12 | main(y,x){
      | ^~~~
main.c: In function 'main':
main.c:12:1: warning: old-style function definition [-Wold-style-definition]
main.c:12:1: error: type of 'y' defaults to 'int' [-Wimplicit-int]
main.c:12:1: error: type of 'x' defaults to 'int' [-Wimplicit-int]
main.c:13:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   13 |         scanf("%d%d",&h,&w);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | char a[3010][3010];
main.c:13:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   13 |         scanf("%d%d",&h,&w);
      |         ^~~~~
main.c:13:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:27:9: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   27 |         printf("%d",r);
      |         ^~~~~~
main.c:27:9: note: include '<stdio.h>

ソースコード

diff #
raw source code

char a[3010][3010];
h,w;r;
f(y,x,l,r){
	l=r=x;
	while(a[y][l-1])a[y][--l]=0;
	while(a[y][r])a[y][r++]=0;
	for(x=l;x<r;++x){
		if(a[y-1][x])f(y-1,x);
		if(a[y+1][x])f(y+1,x);
	}
}
main(y,x){
	scanf("%d%d",&h,&w);
	for(y=1;y<=h;++y){
		for(x=1;x<=w;++x){
			scanf("%d",&a[y][x]);
		}
	}
	for(y=1;y<=h;++y){
		for(x=1;x<=w;++x){
			if(a[y][x]){
				++r;
				f(y,x);
			}
		}
	}
	printf("%d",r);
}
0