Submission #867723

#TimeUsernameProblemLanguageResultExecution timeMemory
867723BoopyTheNoobTracks in the Snow (BOI13_tracks)C++14
0 / 100
42 ms1372 KiB
#include <iostream> #include <vector> #include <deque> using namespace std; int main (void) { int dx[4] = {0, 0, 1, -1}; int dy[4] = {1, -1, 0, 0}; int N, M; scanf("%d %d", &N, &M); vector<string> grid(N); for (int i = 0; i < N; i++) scanf("%s", &grid[i]); vector<vector<int>> dist(N, vector<int>(M, 1e9)); deque<vector<int>> bfs; bfs.push_back({0, 0, 1}); int ans = 0; while (!bfs.empty()) { int x = bfs.front()[0], y = bfs.front()[1], d = bfs.front()[2]; bfs.pop_front(); dist[x][y] = d; ans = max(ans, d); for (int i = 0; i < 4; i++) { int nx = x + dx[i], ny = y + dy[i]; if (nx < 0 || nx >= N || ny < 0 || ny >= M) continue; if (dist[nx][ny] < 1e9 || grid[nx][ny] == '.') continue; vector<int> next = {nx, ny, d}; if (grid[x][y] != grid[nx][ny]) { next[2]++; bfs.push_back(next); } else bfs.push_front(next); } } /*for (auto x: dist) { for (auto y: x) { cout << y << " "; } cout << endl; }*/ printf("%d", ans); return 0; }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:13:17: warning: format '%s' expects argument of type 'char*', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type*' {aka 'std::__cxx11::basic_string<char>*'} [-Wformat=]
   13 |         scanf("%s", &grid[i]);
      |                ~^
      |                 |
      |                 char*
tracks.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %d", &N, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~~
tracks.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%s", &grid[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...