Submission #565097

# Submission time Handle Problem Language Result Execution time Memory
565097 2022-05-20T09:24:29 Z Garguy22 Rainforest Jumps (APIO21_jumps) C++17
0 / 100
1 ms 336 KB
#include <iostream>
#include <vector>
#include <queue>
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
typedef pair<int, int> pii;

vector<int> adj[2007];
bool vis[2007];

void init(int N, vector<int> H){
	for(int i = 0; i < N; i++){
		for(int j = i-1; j >= 0; j--){
			if(H[j] > H[i]){
				adj[i].pb(j);
				break;
			}
		}
		for(int j = i+1; j < N; j++){
			if(H[j] > H[i]){
				adj[i].pb(j);
				break;
			}
		}
	}
}

int minimum_jumps(int A, int B, int C, int D){
	queue<pii> q;
	for(int i = A; i <= B; i++){
		q.push(mp(0, i));
		vis[i] = 1;
	}
	while(!q.empty()){
		pii u = q.front();
		q.pop();
		if(u.ss >= C && u.ss <= D)
			return u.ff;
		for(int v : adj[u.ss]){
			if(!vis[v]){
				q.push(mp(u.ff + 1, u.ss));
				vis[v] = 1;
			}
		}
	}
	return -1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -