結果

問題 No.307 最近色塗る問題多くない?
ユーザー cielciel
提出日時 2015-11-29 01:43:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 140 ms / 4,000 ms
コード長 504 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 23,168 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 16:53:52
合計ジャッジ時間 2,357 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 1 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 4 ms
5,376 KB
testcase_08 AC 18 ms
5,376 KB
testcase_09 AC 8 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 1 ms
5,376 KB
testcase_17 AC 11 ms
5,376 KB
testcase_18 AC 26 ms
5,376 KB
testcase_19 AC 23 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 20 ms
5,376 KB
testcase_22 AC 18 ms
5,376 KB
testcase_23 AC 121 ms
5,376 KB
testcase_24 AC 47 ms
5,376 KB
testcase_25 AC 73 ms
5,376 KB
testcase_26 AC 137 ms
5,376 KB
testcase_27 AC 12 ms
5,376 KB
testcase_28 AC 23 ms
5,376 KB
testcase_29 AC 7 ms
5,376 KB
testcase_30 AC 140 ms
5,376 KB
testcase_31 AC 19 ms
5,376 KB
testcase_32 AC 18 ms
5,376 KB
testcase_33 AC 11 ms
5,376 KB
testcase_34 AC 19 ms
5,376 KB
testcase_35 AC 19 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         for(scanf("%d%d",&H,&W);h<H;h++)for(w=0;w<W;w++)scanf("%d",&a[h][w]);
      |             ~~~~~^~~~~~~~~~~~~~
main.cpp:9:62: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         for(scanf("%d%d",&H,&W);h<H;h++)for(w=0;w<W;w++)scanf("%d",&a[h][w]);
      |                                                         ~~~~~^~~~~~~~~~~~~~~
main.cpp:10:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         for(scanf("%d",&Q);Q;Q--){
      |             ~~~~~^~~~~~~~~
main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 scanf("%d%d%d",&R,&C,&X);R--,C--;
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:14:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         for(;Q--;)scanf("%d%d%d",&R,&C,&Z);
      |                   ~~~~~^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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(){
	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