結果
問題 | No.307 最近色塗る問題多くない? |
ユーザー |
|
提出日時 | 2020-07-28 20:57:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 717 bytes |
コンパイル時間 | 2,222 ms |
コンパイル使用メモリ | 203,748 KB |
最終ジャッジ日時 | 2025-01-12 07:18:00 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 TLE * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | int h,w; scanf("%d%d",&h,&w); | ~~~~~^~~~~~~~~~~~~~ main.cpp:12:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | rep(i,h) rep(j,w) scanf("%d",&B[i][j]); | ~~~~~^~~~~~~~~~~~~~~ main.cpp:14:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | int q; scanf("%d",&q); | ~~~~~^~~~~~~~~ main.cpp:16:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | int y0,x0,c; scanf("%d%d%d",&y0,&x0,&c); y0--; x0--; | ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; const int dx[]={1,0,-1,0},dy[]={0,-1,0,1}; int main(){ int h,w; scanf("%d%d",&h,&w); vector B(h,vector(w,0)); rep(i,h) rep(j,w) scanf("%d",&B[i][j]); int q; scanf("%d",&q); rep(_,q){ int y0,x0,c; scanf("%d%d%d",&y0,&x0,&c); y0--; x0--; if(B[y0][x0]==c) continue; B[y0][x0]=c; queue<pair<int,int>> Q; Q.emplace(y0,x0); while(!Q.empty()){ int y,x; tie(y,x)=Q.front(); Q.pop(); rep(k,4){ int y2=y+dy[k],x2=x+dx[k]; if(0<=y2 && y2<h && 0<=x2 && x2<w && B[y2][x2]!=c){ B[y2][x2]=c; Q.emplace(y2,x2); } } } } rep(i,h) rep(j,w) printf("%d%c",B[i][j],j<w-1?' ':'\n'); return 0; }