結果
問題 |
No.307 最近色塗る問題多くない?
|
ユーザー |
|
提出日時 | 2015-11-29 01:41:40 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 239 ms / 4,000 ms |
コード長 | 526 bytes |
コンパイル時間 | 282 ms |
コンパイル使用メモリ | 21,248 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-14 05:02:55 |
合計ジャッジ時間 | 2,913 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d%d",&H,&W); | ^~~~~~~~~~~~~~~~~~~ main.c:10:49: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | for(int h=0;h<H;h++)for(int w=0;w<W;w++)scanf("%d",&a[h][w]); | ^~~~~~~~~~~~~~~~~~~~ main.c:11:13: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | for(scanf("%d",&Q);Q;Q--){ | ^~~~~~~~~~~~~~ main.c:12:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d%d%d",&R,&C,&X);R--,C--; | ^~~~~~~~~~~~~~~~~~~~~~~~ main.c:15:19: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | for(;Q--;)scanf("%d%d%d",&R,&C,&Z); | ^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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); }