Submission #869006

#TimeUsernameProblemLanguageResultExecution timeMemory
869006bobbilykingTracks in the Snow (BOI13_tracks)C++17
100 / 100
604 ms358288 KiB
#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include<bits/stdc++.h> #include<math.h> using namespace std; typedef long long int ll; typedef long double ld; typedef pair<ll, ll> pl; #define K first #define V second #define G(x) ll x; cin >> x; #define GD(x) ld x; cin >> x; #define GS(s) string s; cin >> s; #define EX(x) { cout << x << '\n'; exit(0); } #define A(a) (a).begin(), (a).end() #define F(i, l, r) for (ll i = (l); i < r; ++i) #define NN #define M 1000000007 // 998244353 string grid[4010]; bool vis[4010][4010]; int main(){ // freopen("a.in", "r", stdin); // freopen("a.out", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); G(h) G(w) F(i, 0, h) cin >> grid[i]; ll dx[4] = {0, -1, 0, 1}; ll dy[4] = {1, 0, -1, 0}; vector<pl> q{pl{0, 0}, pl{h-1, w-1}}; vector<pl> nq; char cur = grid[0][0]; // character we are currently looking at ll iter = 0; vis[0][0] = vis[h-1][w-1] = 1; for (; q.size(); iter++, cur = cur == 'R' ? 'F' : 'R') { F(ha, 0, q.size()) { auto [x, y] = q[ha]; F(k, 0, 4) { ll ni = x + dx[k], nj = y + dy[k]; if (min(ni, nj) >= 0 and ni < h and nj < w and grid[ni][nj] != '.' and !vis[ni][nj]) { vis[ni][nj] = 1; if (grid[ni][nj] == cur) q.emplace_back(ni, nj); else nq.emplace_back(ni, nj); } } } q.clear(); swap(q, nq); } cout << iter << '\n'; }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:20:39: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 | #define F(i, l, r) for (ll i = (l); i < r; ++i)
......
   46 |         F(ha, 0, q.size()) {
      |           ~~~~~~~~~~~~~~~              
tracks.cpp:46:9: note: in expansion of macro 'F'
   46 |         F(ha, 0, q.size()) {
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...