結果

問題 No.307 最近色塗る問題多くない?
コンテスト
ユーザー ciel
提出日時 2015-11-29 01:41:40
言語 C90
(gcc 12.3.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 526 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 299 ms
コンパイル使用メモリ 26,944 KB
最終ジャッジ日時 2025-11-24 06:21:07
合計ジャッジ時間 1,940 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c: In function 'main':
main.c:10:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   10 |         for(int h=0;h<H;h++)for(int w=0;w<W;w++)scanf("%d",&a[h][w]);
      |         ^~~
main.c:10:9: note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code
main.c:10:29: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   10 |         for(int h=0;h<H;h++)for(int w=0;w<W;w++)scanf("%d",&a[h][w]);
      |                             ^~~
main.c:16:17: error: redefinition of 'h'
   16 |         for(int h=0;h<H;h++)for(int w=0;w<W;w++)printf(w<W-1?"%d ":"%d\n",Z<0?a[h][w]:Z);
      |                 ^
main.c:10:17: note: previous definition of 'h' with type 'int'
   10 |         for(int h=0;h<H;h++)for(int w=0;w<W;w++)scanf("%d",&a[h][w]);
      |                 ^
main.c:16:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   16 |         for(int h=0;h<H;h++)for(int w=0;w<W;w++)printf(w<W-1?"%d ":"%d\n",Z<0?a[h][w]:Z);
      |         ^~~
main.c:16:37: error: redefinition of 'w'
   16 |         for(int h=0;h<H;h++)for(int w=0;w<W;w++)printf(w<W-1?"%d ":"%d\n",Z<0?a[h][w]:Z);
      |                                     ^
main.c:10:37: note: previous definition of 'w' with type 'int'
   10 |         for(int h=0;h<H;h++)for(int w=0;w<W;w++)scanf("%d",&a[h][w]);
      |                                     ^
main.c:16:29: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   16 |         for(int h=0;h<H;h++)for(int w=0;w<W;w++)printf(w<W-1?"%d ":"%d\n",Z<0?a[h][w]:Z);
      |                             ^~~

ソースコード

diff #
raw source code

#include <stdio.h>
int a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
int dfs(int x,int y,int 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);
}
int main(){
	scanf("%d%d",&H,&W);
	for(int h=0;h<H;h++)for(int 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(int h=0;h<H;h++)for(int w=0;w<W;w++)printf(w<W-1?"%d ":"%d\n",Z<0?a[h][w]:Z);
}
0