Submission #67039

#TimeUsernameProblemLanguageResultExecution timeMemory
67039RezwanArefin01Tracks in the Snow (BOI13_tracks)C++17
100 / 100
958 ms297244 KiB
///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit; #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; const int N = 4010; char g[N][N]; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int d[N][N], n, m; int main() { scanf("%d %d", &n, &m); for(int i = 0; i < n; i++) scanf(" %s", g[i]); deque<ii> q; memset(d, 63, sizeof d); q.push_back({0, 0}); d[0][0] = 1 ; while(!q.empty()) { ii u = q.front(); q.pop_front(); int x = u.first, y = u.second; for(int i = 0; i < 4; i++) { int xx = x + dx[i], yy = y + dy[i]; if(xx >= 0 && xx < n && yy >= 0 && yy < m && g[xx][yy] != '.') { int c = g[x][y] != g[xx][yy]; if(d[xx][yy] > d[x][y] + c) { d[xx][yy] = d[x][y] + c; if(c) q.push_back({xx, yy}); else q.push_front({xx, yy}); } } } } int mx = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) if(g[i][j] != '.') { mx = max(mx, d[i][j]); } } printf("%d\n", mx); }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
tracks.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s", g[i]); 
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...