제출 #488859

#제출 시각아이디문제언어결과실행 시간메모리
488859cfalas밀림 점프 (APIO21_jumps)C++14
0 / 100
4034 ms2660 KiB
#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; } } FORi(i,1,t+1){ if(!vis[t-i] && a[t-i]>a[t]){ vis[t-i] = true; q.push(t-i); break; } } } if(f) return ans; else return -1; }
#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...