結果
| 問題 | No.307 最近色塗る問題多くない? |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-11-29 01:42:57 |
| 言語 | C90(gcc12) (gcc 12.4.0) |
| 結果 |
AC
|
| 実行時間 | 251 ms / 4,000 ms |
| コード長 | 465 bytes |
| 記録 | |
| コンパイル時間 | 125 ms |
| コンパイル使用メモリ | 30,148 KB |
| 最終ジャッジ日時 | 2026-02-23 19:55:54 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
1 | a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
| ^
main.c: In function ‘main’:
main.c:8:13: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
8 | for(scanf("%d%d",&H,&W);h<H;h++)for(w=0;w<W;w++)scanf("%d",&a[h][w]);
| ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
+++ |+#include <stdio.h>
1 | a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
main.c:14:41: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
14 | 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);
| ^~~~~~
main.c:14:41: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
ソースコード
a[200][200],H,W,Q,R,C,X,Z=-1,h,w;
int dfs(x,y,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);
}
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);
}