제출 #917587

#제출 시각아이디문제언어결과실행 시간메모리
917587hariaakas646밀림 점프 (APIO21_jumps)C++14
0 / 100
4019 ms18212 KiB
#include "jumps.h" #include <bits/stdc++.h> using namespace std; #define scd(t) scanf("%d", &t) #define sclld(t) scanf("%lld", &t) #define forr(i, l, r) for(int i=l; i<r; i++) #define frange(i, l) forr(i, 0, l) #define pb push_back #define mp make_pair #define f first #define s second #define all(x) x.begin(), x.end() typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pii> vii; typedef long long lli; typedef vector<vi> vvi; typedef vector<lli> vll; typedef vector<bool> vb; typedef set<int> seti; typedef multiset<int> mseti; vvi graph; int n; void init(int N, std::vector<int> h) { n = N; graph = vvi(n); set<pii> st1, st2; frange(i, n) st2.insert(mp(h[i], i)); frange(i, n) { st2.erase(mp(h[i], i)); auto it = st1.lower_bound(mp(h[i]+1, 0)); if(it != st1.end()) graph[i].pb((*it).s); it = st2.lower_bound(mp(h[i]+1, 0)); if(it != st2.end()) { graph[i].pb((*it).s); } st1.insert(mp(h[i], i)); } } int minimum_jumps(int A, int B, int C, int D) { queue<pii> q; forr(i, A, B+1) q.push(mp(i, 0)); vb vis(n); while(q.size()) { auto p = q.front(); q.pop(); if(C <= p.f && p.f <= D) return p.s; if(vis[p.f]) continue; vis[p.f] = true; for(auto e : graph[p.f]) { q.push(mp(e, p.s+1)); } } 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...