結果
問題 |
No.307 最近色塗る問題多くない?
|
ユーザー |
![]() |
提出日時 | 2015-11-27 23:36:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 649 bytes |
コンパイル時間 | 1,428 ms |
コンパイル使用メモリ | 158,668 KB |
実行使用メモリ | 13,888 KB |
最終ジャッジ日時 | 2024-09-14 00:53:28 |
合計ジャッジ時間 | 7,439 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 8 TLE * 1 -- * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:18:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf("%d",&a[i][j]); | ~~~~~^~~~~~~~~~~~~~~ main.cpp:21:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | int q; scanf("%d",&q); | ~~~~~^~~~~~~~~ main.cpp:23:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 23 | int r,c,x; scanf("%d %d %d",&r,&c,&x); | ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; int h,w; int a[200][200]; int mx[]={0,0,1,-1},my[]={1,-1,0,0}; void dfs(int i,int j,int c){ int moto=a[i][j]; a[i][j]=c; for(int k=0;k<4;k++){ int ny=i+my[k],nx=j+mx[k]; if(ny<0||h<=ny||nx<0||w<=nx) continue; if(moto==a[ny][nx]) dfs(ny,nx,c); } } int main(){ cin>>h>>w; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ scanf("%d",&a[i][j]); } } int q; scanf("%d",&q); for(int i=0;i<q;i++){ int r,c,x; scanf("%d %d %d",&r,&c,&x); if(x!=a[r-1][c-1]) dfs(r-1,c-1,x); } for(int i=0;i<h;i++){ for(int j=0;j<w;j++) printf("%c%d",j?' ':'\0',a[i][j]); printf("\b\n"); } return 0; }