結果
問題 | No.307 最近色塗る問題多くない? |
ユーザー |
|
提出日時 | 2015-11-29 01:36:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 167 ms / 4,000 ms |
コード長 | 686 bytes |
コンパイル時間 | 370 ms |
コンパイル使用メモリ | 40,704 KB |
実行使用メモリ | 7,040 KB |
最終ジャッジ日時 | 2024-11-21 22:07:45 |
合計ジャッジ時間 | 2,526 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:19:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | scanf("%d%d",&H,&W); | ~~~~~^~~~~~~~~~~~~~ main.cpp:24:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 24 | scanf("%d",&a[h][w]); | ~~~~~^~~~~~~~~~~~~~~ main.cpp:28:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 28 | for(scanf("%d",&Q);Q;Q--){ | ~~~~~^~~~~~~~~ main.cpp:29:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | scanf("%d%d%d",&R,&C,&X); | ~~~~~^~~~~~~~~~~~~~~~~~~ main.cpp:34:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%d%d%d",&R,&C,&Z); | ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include <vector> #include <cstdio> using namespace std; vector<vector<int> >a; int dfs(int x,int y,int c){ if(x<0||a[0].size()<=x || y<0||a.size()<=y || a[y][x]==c)return 0; a[y][x]=c; int r=1; r+=dfs(x-1,y,c); r+=dfs(x+1,y,c); r+=dfs(x,y-1,c); r+=dfs(x,y+1,c); return r; } int main(){ int H,W; scanf("%d%d",&H,&W); a.resize(H); for(int h=0;h<H;h++){ a[h].resize(W); for(int w=0;w<W;w++){ scanf("%d",&a[h][w]); } } int Q,R,C,X,Z=-1; 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;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); }