Submission #1047483

#TimeUsernameProblemLanguageResultExecution timeMemory
1047483SN0WM4NRainforest Jumps (APIO21_jumps)C++14
21 / 100
4065 ms7348 KiB
#include "jumps.h" #include <bits/stdc++.h> using namespace std; vector<int> v; vector<int> m_sig, m_prev; void init(int N, std::vector<int> H) { v = H; m_sig.resize(N); m_prev.resize(N); for (int i = N - 1; i >= 0; i --) { m_sig[i] = i; m_prev[i] = i; for (int j = i; j < N; j ++) { if (H[j] > H[i]) { m_sig[i] = j; break; } } for (int j = i; j >= 0; j --) { if (H[j] > H[i]) { m_prev[i] = j; break; } } } } int minimum_jumps(int A, int B, int C, int D) { vector<int> vis(v.size(), 1e9); queue<pair<int, int>> q; for (int i = A; i <= B; i ++) q.push({i, 0}); while (!q.empty()) { auto [x, d] = q.front(); q.pop(); if (vis[x] <= d) continue; if (C <= x && x <= D) return d; vis[x] = d; q.push({m_sig[x], d + 1}); q.push({m_prev[x], d + 1}); } return -1; }

Compilation message (stderr)

jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:41:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   41 |                 auto [x, d] = q.front();
      |                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...