# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
570039 | Cyber_Wolf | Rainforest Jumps (APIO21_jumps) | C++14 | 4061 ms | 1048576 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |