# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1048000 | Maite_Morale | Rainforest Jumps (APIO21_jumps) | C++17 | 164 ms | 31832 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vll vector<ll>
#define MAX 2005
#define oo 1e18
#define pll pair<ll,ll>
#define F first
#define S second
const ll bts=20;
pll p[MAX];
vll v[MAX];
ll N,pass[MAX][MAX];
void bfs(ll x){
queue<ll> q;
q.push(x);pass[x][x]=0;
while(!q.empty()){
ll u=q.front();q.pop();
for(auto w : v[u]){
if(pass[x][w]!=-1)continue;
pass[x][w]=pass[x][u]+1;
q.push(w);
}
}
}
void init(int n, std::vector<int> h) {
h.push_back(oo);
stack<ll> s;s.push(n);
for(int i=0;i<n;i++){
while(h[i]>h[s.top()]){
p[s.top()].F=i;
if(s.top()!=n)v[s.top()].push_back(i);
s.pop();
}
p[i].S=s.top();
if(s.top()!=n) v[i].push_back(s.top());
s.push(i);
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
pass[i][j]=-1;
}
bfs(i);
}
}
int minimum_jumps(int A, int B, int C, int D) {
ll r=oo;
for(int i=A;i<=B;i++){
for(int j=C;j<=D;j++){
if(pass[i][j]!=-1){
r=min(r,pass[i][j]);
}
}
}
if(r==oo)return -1;
return r;
}
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... |