# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
474869 | dqk | Tracks in the Snow (BOI13_tracks) | C++17 | 669 ms | 123868 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>
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m;
std::cin >> n >> m;
std::string g[n];
for (int i = 0; i < n; ++i) {
std::cin >> g[i];
}
auto inside=[&](int x, int y) {
if (x >= 0 && x < n && y >= 0 && y < m && g[x][y] != '.')
return true;
return false;
};
std::vector<int> dx={1, -1, 0, 0}, dy={0, 0, 1, -1};
std::vector<std::vector<int>> d(n, std::vector<int>(m, 0));
std::deque<std::pair<int, int>> q;
q.push_back({0, 0});
d[0][0] = 1;
int ans = 0;
while (!q.empty()) {
auto u = q.front();
q.pop_front();
ans = std::max(ans, d[u.first][u.second]);
for (int i = 0; i < 4; ++i) {
int x = u.first + dx[i];
int y = u.second + dy[i];
if (!inside(x, y))
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |