-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path784.cpp
More file actions
40 lines (39 loc) · 888 Bytes
/
784.cpp
File metadata and controls
40 lines (39 loc) · 888 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
35
36
37
38
39
40
#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
char a[100][100];
int N, M;
void call(int i, int j) {
M = strlen(a[i]);
if (i < 0 || j < 0 || i >= N || j >= M) return;
if (a[i][j] != ' ' && a[i][j] != '*') return;
a[i][j] = '#';
for (int k = 0; k < 8; k++) {
call(i + dx[k], j + dy[k]);
}
return;
}
int main() {
int n, m, i, j, k, tc, t = 1;
cin >> tc;
getchar();
while (tc--) {
i = 0;
while (gets(a[i])) {
if (a[i][0] == '_') break;
i++;
}
N = i;
for (i = 0; i < N; i++) {
M = strlen(a[i]);
for (j = 0; j < M; j++) {
if (a[i][j] == '*') {
call(i, j);
}
}
}
for (i = 0; i <= N; i++) puts(a[i]);
}
return 0;
}