Submission #877686

#TimeUsernameProblemLanguageResultExecution timeMemory
877686Beerus13Tracks in the Snow (BOI13_tracks)C++14
100 / 100
581 ms59188 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 4e3 + 5; int h, w; string s[N]; int dx[] = {-1, 0, 0, 1}; int dy[] = {0, -1, 1, 0}; bool vs[N][N]; queue<pair<int, int>> q[2]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> h >> w; for(int i = 0; i < h; ++i) cin >> s[i]; bool cur = (s[0][0] == 'F'); vs[0][0] = 1; q[cur].emplace(0, 0); int cnt = 0; while(q[0].size() || q[1].size()) { while(q[cur].size()) { auto [u, v] = q[cur].front(); q[cur].pop(); for(int i = 0; i < 4; ++i) { int x = u + dx[i]; int y = v + dy[i]; if(x < 0 || x >= h || y < 0 || y >= w) continue; if(vs[x][y] || s[x][y] == '.') continue; vs[x][y] = 1; bool tmp = (s[x][y] == 'F'); q[tmp].emplace(x, y); } } ++cnt; cur ^= 1; } cout << cnt; return 0; }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:24:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   24 |             auto [u, v] = q[cur].front(); q[cur].pop();
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...