Submission #389913

#TimeUsernameProblemLanguageResultExecution timeMemory
389913null_aweTracks in the Snow (BOI13_tracks)C++14
2.19 / 100
368 ms30688 KiB
#include <bits/stdc++.h> using namespace std; vector<int> dx{-1, 1, 0, 0}, dy{0, 0, -1, 1}; int main() { int h, w, rank[h][w]; cin >> h >> w; vector<string> field(h); for (int i = 0; i < h; ++i) cin >> field[i]; int m = 1; rank[0][0] = 1; deque<vector<int>> q; vector<int> first{0, 0}; q.push_back(first); while (!q.empty()) { vector<int> s = q.front(); m = max(m, rank[s[0]][s[1]]); q.pop_front(); for (int i = 0; i < 4; ++i) { int x = s[0] + dx[i], y = s[1] + dy[i]; if (x < 0 || y < 0 || x >= h || y >= w || rank[x][y] > 0 || field[x][y] == '.') continue; vector<int> add{x, y}; int r = rank[s[0]][s[1]]; if (field[s[0]][s[1]] == field[x][y]) { q.push_front(add); rank[x][y] = r; } else { q.push_back(add); rank[x][y] = r + 1; } } } cout << m; return 0; }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:7:22: warning: 'w' is used uninitialized in this function [-Wuninitialized]
    7 |   int h, w, rank[h][w];
      |                      ^
tracks.cpp:7:22: warning: 'h' is used uninitialized in this function [-Wuninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...