# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
394172 | SirCovidThe19th | Tracks in the Snow (BOI13_tracks) | C++14 | 1482 ms | 122428 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;
int main() {
int h, w;
cin >> h >> w;
char grid[h][w];
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
cin >> grid[i][j];
int ans = 0;
int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1};
int depth[h][w];
deque<pair<int, int>> trav;
memset(depth, 0, sizeof(depth));
depth[0][0] = 1; trav.push_back({0, 0});
while (!trav.empty()){
pair<int, int> curr = trav.front(); trav.pop_front();
ans = max(ans, depth[curr.first][curr.second]);
for (int i = 0; i < 4; i++){
int x = curr.first+dx[i]; int y = curr.second+dy[i];
if (x < 0 or x >= h or y < 0 or y >= w or grid[x][y] == '.' or depth[x][y] != 0) continue;
if (grid[x][y] == grid[curr.first][curr.second]){
depth[x][y] = depth[curr.first][curr.second];
trav.push_front({x, y});
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |