-
Notifications
You must be signed in to change notification settings - Fork 0
/
봄버맨.cc
82 lines (77 loc) · 1.81 KB
/
봄버맨.cc
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int r, c, n;
vector<vector<char>> now;
vector<vector<char>> all;
void dfs(int i, int j) {
if (i < 0 || i >= r || j < 0 || j >= c)
return;
all[i][j] = '.';
}
void bomb() {
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++){
if (now[i][j] == 'O') {
dfs(i, j);
dfs(i-1, j);
dfs(i+1, j);
dfs(i, j-1);
dfs(i, j+1);
}
}
}
now = all;
all.assign(r,vector<char>(c,'O'));
}
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(NULL);
//freopen("input.txt", "r", stdin);
cin >> r >> c >> n;
now.assign(r,vector<char>(c,'O'));
all.assign(r,vector<char>(c,'O'));
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++){
char t;
cin >> t;
if (t == '.') {
now[i][j] = '.';
}
}
}
if (n == 1) {
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++){
cout << now[i][j];
}
cout << '\n';
}
}
else if (n % 2 == 0) {
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++){
cout << all[i][j];
}
cout << '\n';
}
} else {
if (n % 4 == 3) {
bomb();
} else if (n % 4 == 1) {
bomb();
bomb();
}
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++){
cout << now[i][j];
}
cout << '\n';
}
}
return 0;
}