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<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID ((l+r)/2)
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;
#define EPS 1e-6
#define FOR(i,n) for(int i=0;i<((int)(n));i++)
#define FORi(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define FOA(v, a) for(auto v : a)
int t, n;
vi a, b;
void init(int N, std::vector<int> H) {
n = N;
a.resize(n);
FOR(i,n) a[i] = H[i];
}
int minimum_jumps(int A, int B, int C, int D) {
queue<int> q;
vi vis(n+1, false);
FORi(i,A,B+1) q.push(i), vis[i] = true;
q.push(-1);
int ans=0;
bool f = false;
while(q.size()>1){
int t = q.front();
q.pop();
if(t==-1){
ans++;
q.push(-1);
continue;
}
if(C<=t && t<=D){
f = true;
break;
}
FORi(i,t+1,n){
if(!vis[i] && a[i]>a[t]){
vis[i] = true;
q.push(i);
break;
}
else if(a[i]>a[t]) break;
}
FORi(i,1,t+1){
if(!vis[t-i] && a[t-i]>a[t]){
vis[t-i] = true;
q.push(t-i);
break;
}
else if(a[t-i]>a[t]) break;
}
}
if(f) return ans;
else return -1;
}
# | 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... |