forked from abeaumont/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path00784.cc
More file actions
34 lines (34 loc) · 715 Bytes
/
00784.cc
File metadata and controls
34 lines (34 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// https://uva.onlinejudge.org/external/7/784.pdf
#include<bits/stdc++.h>
using namespace std;
using vs=vector<string>;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin>>t;
string s;
getline(cin,s);
while(t--){
vs a;
for(;;){
getline(cin,s);
a.push_back(s);
if(s[0]=='_')break;
}
function<void(int,int)>dfs=[&](int y,int x){
a[y][x]='#';
int r[]={-1,0,1,0};
int c[]={0,1,0,-1};
for(int i=0;i<4;i++){
int u=y+r[i],v=x+c[i];
if(a[u][v]==' ')dfs(u,v);
}
};
for(int i=0;i<a.size();i++)
for(int j=0;j<a[i].size();j++)
if(a[i][j]=='*')
dfs(i,j);
for(auto s:a)cout<<s<<"\n";
}
}