제출 #1167271

#제출 시각아이디문제언어결과실행 시간메모리
1167271adriannok밀림 점프 (APIO21_jumps)C++20
0 / 100
4046 ms12520 KiB
#include "jumps.h"

#include <bits/stdc++.h>

using namespace std;

int N; 
vector<int> H;
vector<int> sorted;
vector< unordered_map<int, int> > d;
unordered_map<int, int> id;

void washifloi_Init()
{
	for (int k = 0; k < N; ++k)
		for (int i = 0; i < N; ++i)
			for(int j = 0; j < N; ++j)
				if( d[i].count(k) && d[k].count(i) )
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

void verify(const int& i, const int& j, int &in)
{
	if(H[j] > H[i] && H[j] < (in<N? H[in] : N+1))
		in = j;
}

void init(int n, vector<int> h) 
{
	N = n;
	H = h;
	d.resize( N );
	
	for (int i = 0; i < n; ++i)
	{
		int in = N+1;
		for (int j = i+1; j < n; ++j)
		{
			verify(i, j, in);
		}
		if(in < N)
			d[i][in] = 1;
		
		in = N+1;
		for (int j = i-1; j >= 0; --j)
		{
			verify(i, j, in);
		}
		if(in < N)
			d[i][in] = 1;
		
		
	}
	
	washifloi_Init();
}

int minimum_jumps(int A, int B, int C, int D)
{
	int minJ = N+1;
	for(int i = A; i <= B; ++i)
		for(int j = C; j <= D; ++j)
		{
			minJ = min(minJ, d[i][j]);
		}
	
	if(minJ == N+1)
		minJ = -1;
	return minJ;
}
#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...