結果
問題 | No.2946 Puyo |
ユーザー |
|
提出日時 | 2024-10-25 21:24:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 68 ms / 2,000 ms |
コード長 | 783 bytes |
コンパイル時間 | 800 ms |
コンパイル使用メモリ | 72,872 KB |
実行使用メモリ | 9,292 KB |
最終ジャッジ日時 | 2024-10-25 21:24:34 |
合計ジャッジ時間 | 4,478 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:22:29: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 22 | auto[x,y]=Q[k]; | ^ main.cpp:33:25: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 33 | for(auto[x,y]:Q)sz[x][y]=Q.size(); | ^
ソースコード
#include<iostream> #include<vector> #include<cassert> using namespace std; const int d[5]={0,1,0,-1}; int H,W; string G[1000]; int sz[1000][1000]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>H>>W; for(int i=0;i<H;i++)cin>>G[i]; for(int i=0;i<H;i++)for(int j=0;j<W;j++)if(sz[i][j]==0) { vector<pair<int,int> >Q; Q.push_back(make_pair(i,j)); sz[i][j]=-1; for(int k=0;k<Q.size();k++) { auto[x,y]=Q[k]; for(int r=0;r<4;r++) { int tx=x+d[r],ty=y+d[r+1]; if(tx>=0&&ty>=0&&tx<H&&ty<W&&G[x][y]==G[tx][ty]&&sz[tx][ty]==0) { sz[tx][ty]=-1; Q.push_back(make_pair(tx,ty)); } } } for(auto[x,y]:Q)sz[x][y]=Q.size(); } for(int i=0;i<H;i++) { for(int j=0;j<W;j++)cout<<(sz[i][j]>=4?'.':G[i][j]); cout<<"\n"; } }