結果

問題 No.307 最近色塗る問題多くない?
ユーザー ciel
提出日時 2015-11-29 01:42:57
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 139 ms / 4,000 ms
コード長 465 bytes
コンパイル時間 119 ms
コンパイル使用メモリ 20,608 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-21 22:09:35
合計ジャッジ時間 2,025 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
    1 | a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
      | ^
main.c:1:1: warning: type defaults to ‘int’ in declaration of ‘a’ [-Wimplicit-int]
main.c:1:13: warning: type defaults to ‘int’ in declaration of ‘H’ [-Wimplicit-int]
    1 | a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
      |             ^
main.c:1:15: warning: type defaults to ‘int’ in declaration of ‘W’ [-Wimplicit-int]
    1 | a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
      |               ^
main.c:1:17: warning: type defaults to ‘int’ in declaration of ‘Q’ [-Wimplicit-int]
    1 | a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
      |                 ^
main.c:1:19: warning: type defaults to ‘int’ in declaration of ‘R’ [-Wimplicit-int]
    1 | a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
      |                   ^
main.c:1:21: warning: type defaults to ‘int’ in declaration of ‘C’ [-Wimplicit-int]
    1 | a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
      |                     ^
main.c:1:23: warning: type defaults to ‘int’ in declaration of ‘X’ [-Wimplicit-int]
    1 | a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
      |                       ^
main.c:1:25: warning: type defaults to ‘int’ in declaration of ‘Z’ [-Wimplicit-int]
    1 | a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
      |                         ^
main.c:1:30: warning: type defaults to ‘int’ in declaration of ‘h’ [-Wimplicit-int]
    1 | a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
      |                              ^
main.c:1:32: warning: type defaults to ‘int’ in declaration of ‘w’ [-Wimplicit-int]
    1 | a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
      |                                ^
main.c: In function ‘dfs’:
main.c:2:5: warning: type of ‘x’ defaults to ‘int’ [-Wimplicit-int]
    2 | int dfs(x,y,c){
      |     ^~~
main.c:2:5: warning: type of ‘y’ defaults to ‘int’ [-Wimplicit-int]
main.c:2:5: warning: type of ‘c’ defaults to ‘int’ [-Wimplicit-int]
main.c: At

ソースコード

diff #

a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
int dfs(x,y,c){
	if(x<0||W<=x || y<0||H<=y || a[y][x]==c)return 0;
	a[y][x]=c;
	return 1+dfs(x-1,y,c)+dfs(x+1,y,c)+dfs(x,y-1,c)+dfs(x,y+1,c);
}
main(){
	for(scanf("%d%d",&H,&W);h<H;h++)for(w=0;w<W;w++)scanf("%d",&a[h][w]);
	for(scanf("%d",&Q);Q;Q--){
		scanf("%d%d%d",&R,&C,&X);R--,C--;
		if(dfs(C,R,X)==H*W)break;
	}
	for(;Q--;)scanf("%d%d%d",&R,&C,&Z);
	for(h=0;h<H;h++)for(w=0;w<W;w++)printf(w<W-1?"%d ":"%d\n",Z<0?a[h][w]:Z);
}
0