Submission #1322359

#TimeUsernameProblemLanguageResultExecution timeMemory
1322359alexandrosTracks in the Snow (BOI13_tracks)C++20
100 / 100
1108 ms269680 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<vector<int>> vec; deque<pair<ll, ll>> dq; vector<vector<ll>> dist; int main() { ll width, height; char cur; scanf("%lld %lld", &height, &width); vec.assign(height, vector<int>(width, 0)); for(ll i = 0; i < height; i++) { for(ll j = 0; j < width; j++) { scanf(" %c", &cur); if(cur == 'R') { vec[i][j] = 1; } else if(cur == 'F') { vec[i][j] = 2; } } } dist.assign(height, vector<ll>(width, -1)); dq.push_back({0, 0}); dist[0][0] = 1; pair<ll, ll> tp; ll big = 1; while(!dq.empty()) { tp = dq.front(); dq.pop_front(); for(ll i = -1; i <= 1; i++) { for(ll j = -1; j <= 1; j++) { if(i != 0 && j != 0) continue; if(i == 0 && j == 0) continue; ll ni = tp.first + i; ll nj = tp.second + j; if(ni < 0 || nj < 0) continue; if(ni >= height || nj >= width) continue; if(dist[ni][nj] != -1) continue; if(vec[ni][nj] == 0) continue; dist[ni][nj] = dist[tp.first][tp.second]; if(vec[ni][nj] == vec[tp.first][tp.second]) dq.push_front({ni, nj}); else { dq.push_back({ni, nj}); dist[ni][nj]++; } big = max(big, dist[ni][nj]); } } } printf("%lld", big); }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%lld %lld", &height, &width);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:21:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |             scanf(" %c", &cur);
      |             ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...