結果

問題 No.307 最近色塗る問題多くない?
ユーザー tailstails
提出日時 2015-11-27 23:30:55
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 121 ms / 4,000 ms
コード長 500 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 21,504 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 16:36:54
合計ジャッジ時間 2,499 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 16 ms
5,376 KB
testcase_09 AC 7 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 6 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 10 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 9 ms
5,376 KB
testcase_18 AC 23 ms
5,376 KB
testcase_19 AC 19 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 16 ms
5,376 KB
testcase_22 AC 16 ms
5,376 KB
testcase_23 AC 99 ms
5,376 KB
testcase_24 AC 40 ms
5,376 KB
testcase_25 AC 65 ms
5,376 KB
testcase_26 AC 121 ms
5,376 KB
testcase_27 AC 13 ms
5,376 KB
testcase_28 AC 23 ms
5,376 KB
testcase_29 AC 7 ms
5,376 KB
testcase_30 AC 117 ms
5,376 KB
testcase_31 AC 19 ms
5,376 KB
testcase_32 AC 18 ms
5,376 KB
testcase_33 AC 9 ms
5,376 KB
testcase_34 AC 18 ms
5,376 KB
testcase_35 AC 19 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
    1 | 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
    1 | 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
    1 | 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
    1 | 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
    1 | 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
    2 | 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]
    4 | 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]
   17 | 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]
   17 | z(x){scanf("%d",&x);return x;}
      |      ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
  +++ |+#include <stdio.h>
    1 | h;w;t;c;d;
main.c:17:6: warning: incompatible implicit de

ソースコード

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