#include <bits/stdc++.h>
using std::vector;
using std::array;
using std::pair;
using std::tuple;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int N, M;
std::cin >> N >> M;
vector grid(N, vector<char>(M));
for (int i = 0; i < N; ++i) {
for (int j = 0; j < M; ++j) {
std::cin >> grid[i][j];
char c = grid[i][j];
if (i > 0 and grid[i - 1][j] == '#') c = '#';
if (j > 0 and grid[i][j - 1] == '#') c = '#';
if (i > 0 and j > 0 and grid[i - 1][j - 1] == '#') c = '#';
std::cout << c;
}
std::cout << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |