# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
822758 | Minindu206 | Memory (IOI10_memory) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
void init()
{
#ifndef ONLINE_JUDGE
freopen("input.in", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
int n, m, k;
void bfs(vector<string> &arr)
{
queue<pair<int, int>> q;
q.push({0, 0});
vector<pair<int, int>> dir{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
while (!q.empty())
{
int x = q.front().first;
int y = q.front().second;
q.pop();
arr[x][y] = 'O';
for (pair<int, int> p : dir)
{
int cx = x + p.first;
int cy = y + p.second;
if (cx < 0 || cy < 0 || cx >= n || cy >= m)
continue;
if(arr[cx][cy] != '.')
continue;
q.push({cx, cy});
}
}
}
int main()
{
init();
cin >> n >> m >> k;
string a(m, '.');
string b(m, 'X');
vector<string> arr(n);
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
bfs(arr);
for (int i = 0; i < n; i++)
cout << arr[i] << "\n";
}