# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
159013 | FutymyClone | Tracks in the Snow (BOI13_tracks) | C++14 | 1242 ms | 1048580 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;
const int N = 4005;
int n, m, ans = 0;
bool visited[N][N];
string a[N];
int dx[4] = {0, -1, 0, 1};
int dy[4] = {-1, 0, 1, 0};
bool ok (int x, int y) {
return (x >= 1 && x <= n && y >= 1 && y <= m && !visited[x][y] && a[x][y] != '.');
}
void bfs (queue <pair <int, int> > q1, queue <pair <int, int> > q2) {
if (q1.empty()) return;
ans++;
while (!q1.empty()) {
int x = q1.front().first, y = q1.front().second; q1.pop();
for (int i = 0; i < 4; i++) {
int nx = x + dx[i];
int ny = y + dy[i];
if (!ok(nx, ny)) continue;
visited[nx][ny] = true;
if (a[nx][ny] == a[x][y]) q1.push({nx, ny});
else q2.push({nx, ny});
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |