# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
888333 | alan_c | Tracks in the Snow (BOI13_tracks) | C++17 | 349 ms | 101728 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 = 4000, x[4] = {0, 0, -1, 1}, y[4] = {-1, 1, 0, 0};
string t[N];
bitset<N> v[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int h, w; cin >> h >> w;
for (int i = 0; i < h; i++) cin >> t[i];
int ans = 1;
struct node {
int r, c, d;
};
deque<node> bfs;
bfs.push_back({0, 0, 1});
while (!bfs.empty()) {
node n = bfs.front();
bfs.pop_front();
ans = max(ans, n.d);
for (int i = 0; i < 4; i++) {
int r = n.r + x[i], c = n.c + y[i];
if (r >= 0 && r < h && c >= 0 && c < w && !v[r][c] && t[r][c] != '.') {
if (t[r][c] == t[n.r][n.c])
bfs.push_front({r, c, n.d});
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |