結果
| 問題 |
No.2946 Puyo
|
| コンテスト | |
| ユーザー |
Today03
|
| 提出日時 | 2024-10-25 21:29:03 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 111 ms / 2,000 ms |
| コード長 | 856 bytes |
| コンパイル時間 | 3,408 ms |
| コンパイル使用メモリ | 258,384 KB |
| 実行使用メモリ | 13,140 KB |
| 最終ジャッジ日時 | 2024-10-25 21:29:17 |
| 合計ジャッジ時間 | 7,491 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 45 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF=1e9+10;
const ll INFL=4e18;
int main(){
int H,W;cin>>H>>W;
vector<string>S(H);
for(int i=0;i<H;i++)cin>>S[i];
int id=-1;
vector<vector<int>>par(H,vector<int>(W,-1));
vector<int>sz(H*W,0);
for(int i=0;i<H;i++)for(int j=0;j<W;j++){
if(par[i][j]!=-1)continue;
par[i][j]=++id;
queue<pair<int,int>>que;
que.push({i,j});
while(!que.empty()){
auto[x,y]=que.front();que.pop();
sz[id]++;
for(auto[dx,dy]:{pair{0,1},{1,0},{0,-1},{-1,0}}){
int nx=x+dx,ny=y+dy;
if(nx<0||nx>=H||ny<0||ny>=W)continue;
if(par[nx][ny]!=-1)continue;
if(S[nx][ny]!=S[x][y])continue;
par[nx][ny]=id;
que.push({nx,ny});
}
}
}
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
if(sz[par[i][j]]>=4)cout<<'.';
else cout<<S[i][j];
}
cout<<endl;
}
}
Today03