# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
907611 | cogentcoder73 | Tracks in the Snow (BOI13_tracks) | C++17 | 772 ms | 126460 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 INF = 2147483647;
int main() {
int H, W;
cin >> H >> W;
vector<string> meadow(H);
for (int i = 0; i < H; i++) cin >> meadow[i];
vector<vector<int>> dists(H, vector<int>(W, INF));
dists[0][0] = 1;
deque<pair<int, int>> q; q.push_back({0, 0});
pair<int, int> cur; char curC, newC;
while (!q.empty()) {
cur = q.front();
q.pop_front();
curC = meadow[cur.first][cur.second];
if (cur.first > 0) {
newC = meadow[cur.first - 1][cur.second];
if (newC == curC) {
if (dists[cur.first][cur.second] < dists[cur.first - 1][cur.second]) {
dists[cur.first - 1][cur.second] = dists[cur.first][cur.second];
q.push_front({cur.first - 1, cur.second});
}
} else if (newC != '.') {
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |