Submission #570039

#TimeUsernameProblemLanguageResultExecution timeMemory
570039Cyber_WolfRainforest Jumps (APIO21_jumps)C++14
0 / 100
4061 ms1048576 KiB
#include "jumps.h" //#include "stub.cpp" #include <bits/stdc++.h> using namespace std; #define lg long long const lg sz = 2e5+5; lg n; vector<lg> h(sz); vector<lg> adj[sz]; void init(int N, std::vector<int> H) { n = N; lg mxm = LLONG_MIN, mxmI = -1; for(int i = 0; i < n; i++) { h[i] = H[i]; lg idx = i-1; while(idx >= 0) { if(h[idx] > h[i]) { adj[i].push_back(idx); break; } idx--; } } mxmI = n-1, mxm = h[n-1]; for(int i = n-2; i >= 0; i--) { lg idx = i+1; while(idx < n) { if(h[idx] > h[i]) { adj[i].push_back(idx); break; } idx++; } } } int minimum_jumps(int A, int B, int C, int D) { lg ans = -1; queue<lg> q; for(int i = A; i <= B; i++) q.push(i); lg dist = 0; while(q.size() && ans == -1) { lg sz = q.size(); dist++; while(sz-- && ans == -1) { lg u = q.front(); q.pop(); for(auto it : adj[u]) { if(it >= C && it <= D) { ans = dist; break; } q.push(it); } } } return ans; }

Compilation message (stderr)

jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:18:5: warning: variable 'mxm' set but not used [-Wunused-but-set-variable]
   18 |  lg mxm = LLONG_MIN, mxmI = -1;
      |     ^~~
jumps.cpp:18:22: warning: variable 'mxmI' set but not used [-Wunused-but-set-variable]
   18 |  lg mxm = LLONG_MIN, mxmI = -1;
      |                      ^~~~
#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...