結果

問題 No.307 最近色塗る問題多くない?
ユーザー tailstails
提出日時 2015-11-27 23:30:55
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 132 ms / 4,000 ms
コード長 500 bytes
コンパイル時間 652 ms
コンパイル使用メモリ 24,212 KB
実行使用メモリ 4,436 KB
最終ジャッジ日時 2023-08-14 03:46:26
合計ジャッジ時間 3,000 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 16 ms
4,376 KB
testcase_09 AC 7 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 11 ms
4,380 KB
testcase_14 AC 1 ms
4,388 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 23 ms
4,376 KB
testcase_19 AC 22 ms
4,384 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 17 ms
4,380 KB
testcase_22 AC 17 ms
4,380 KB
testcase_23 AC 108 ms
4,400 KB
testcase_24 AC 44 ms
4,380 KB
testcase_25 AC 69 ms
4,376 KB
testcase_26 AC 128 ms
4,380 KB
testcase_27 AC 11 ms
4,384 KB
testcase_28 AC 23 ms
4,420 KB
testcase_29 AC 7 ms
4,376 KB
testcase_30 AC 132 ms
4,436 KB
testcase_31 AC 19 ms
4,376 KB
testcase_32 AC 18 ms
4,380 KB
testcase_33 AC 10 ms
4,432 KB
testcase_34 AC 18 ms
4,380 KB
testcase_35 AC 19 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
 h;w;t;c;d;
 ^
main.c:1:1: warning: type defaults to ‘int’ in declaration of ‘h’ [-Wimplicit-int]
main.c:1:3: warning: data definition has no type or storage class
 h;w;t;c;d;
   ^
main.c:1:3: warning: type defaults to ‘int’ in declaration of ‘w’ [-Wimplicit-int]
main.c:1:5: warning: data definition has no type or storage class
 h;w;t;c;d;
     ^
main.c:1:5: warning: type defaults to ‘int’ in declaration of ‘t’ [-Wimplicit-int]
main.c:1:7: warning: data definition has no type or storage class
 h;w;t;c;d;
       ^
main.c:1:7: warning: type defaults to ‘int’ in declaration of ‘c’ [-Wimplicit-int]
main.c:1:9: warning: data definition has no type or storage class
 h;w;t;c;d;
         ^
main.c:1:9: warning: type defaults to ‘int’ in declaration of ‘d’ [-Wimplicit-int]
main.c:2:1: warning: data definition has no type or storage class
 f[200][200];
 ^
main.c:2:1: warning: type defaults to ‘int’ in declaration of ‘f’ [-Wimplicit-int]
main.c:4:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
 g(x,y){
 ^
main.c: In function ‘g’:
main.c:4:1: warning: type of ‘x’ defaults to ‘int’ [-Wimplicit-int]
main.c:4:1: warning: type of ‘y’ defaults to ‘int’ [-Wimplicit-int]
main.c: At top level:
main.c:17:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
 z(x){scanf("%d",&x);return x;}
 ^
main.c: In function ‘z’:
main.c:17:1: warning: type of ‘x’ defaults to ‘int’ [-Wimplicit-int]
main.c:17:6: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
 z(x){scanf("%d",&x);return x;}
      ^~~~~
main.c:17:6: warning: incompatible implicit declaration of built-in function ‘scanf’
main.c:17:6: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
main.c:1:1:
+#include <stdio.h>
 h;w;t;c;d;
main.c:17:6:
 z(x){scanf("%d",&x);return x;}
      ^~~~~
main.c: At top level:
main.

ソースコード

diff #

h;w;t;c;d;
f[200][200];

g(x,y){
	if(x>=0&&x<w&&y>=0&&y<h){
		if(f[y][x]==c){
			f[y][x]=d;
			++t;
			g(x-1,y);
			g(x+1,y);
			g(x,y-1);
			g(x,y+1);
		}
	}
}

z(x){scanf("%d",&x);return x;}

main(x,y,q){
	h=z();w=z();
	for(y=0;y<h;++y){
		for(x=0;x<w;++x){
			f[y][x]=z();
		}
	}

	q=z();
	while(q--){
		y=z()-1;x=z()-1;d=z();
		if(t<h*w && f[y][x]!=d){
			t=0;
			c=1-d;
			g(x,y);
		}
	}

	for(y=0;y<h;++y){
		for(x=0;x<w;++x){
			printf("%d%c",t<h*w?f[y][x]:d,x==w-1?10:32);
		}
	}
	return 0;
}
0