# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
932257 |
2024-02-23T06:38:35 Z |
salmon |
Sky Walking (IOI19_walk) |
C++14 |
|
60 ms |
29888 KB |
#include "walk.h"
#include <bits/stdc++.h>
using namespace std;
map<int,pair<int,int>> sky[100100];
map<int,long long int> d[100100];
map<int,set<int>> uber;
set<int> sat;
vector<pair<int,int>> v;
vector<pair<int,int>> w;
priority_queue<pair<long long int, pair<int,int>>,vector<pair<long long int, pair<int,int>>>,greater<pair<long long int, pair<int,int>>>> pq;
long long min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int s, int g) {
int N = x.size();
for(int i = 0; i < N; i++){
l.push_back(i);
r.push_back(i);
y.push_back(0);
v.push_back({h[i],i});
sat.insert(i);
}
sort(v.begin(),v.end(),greater<pair<int,int>>());
int M = l.size();
for(int i = 0; i < M; i++){
w.push_back({y[i],i});
}
sort(w.begin(),w.end());
for(int i = 0; i < M; i++){
while(v.back().first < w[i].first){
sat.erase(v.back().second);
v.pop_back();
}
int j = w[i].second;
auto it = sat.lower_bound(l[j]);
while(it != sat.end() && (*it) <= r[j]){
int k = (*it);
uber[y[j]].insert(*it);
if(sky[k].find(y[j]) != sky[j].end()){
sky[k][y[j]].first = min(sky[j][y[j]].first,l[j]);
sky[k][y[j]].second = max(sky[j][y[j]].second,r[j]);
}
else{
sky[k][y[j]] = make_pair(l[j],r[j]);
}
advance(it,1);
}
}
pq.push({0,{s,0}});
while(!pq.empty()){
pair<long long int, pair<int,int>> iii = pq.top();
pq.pop();
pair<int,int> ii = iii.second;
if(d[ii.first].find(ii.second) != d[ii.first].end()){
continue;
}
d[ii.first][ii.second] = iii.first;
auto it = sky[ii.first].find(ii.second);
advance(it,1);
if(it != sky[ii.first].end()){
pq.push({iii.first + (it -> first) - ii.second, {ii.first, it -> first}});
}
advance(it,-1);
if(it != sky[ii.first].begin()){
advance(it,-1);
pq.push({iii.first + ii.second - (it -> first), {ii.first, it -> first}});
}
auto grab = uber[ii.second].find(ii.first);
advance(grab,1);
if(grab != uber[ii.second].end() && (*grab) <= sky[ii.first][ii.second].second){
pq.push({iii.first + x[(*grab)] - x[ii.first], {(*grab), ii.second}});
}
advance(grab,-1);
if(grab != uber[ii.second].begin()){
advance(grab,-1);
if(sky[ii.first][ii.second].first <= (*grab) ){
pq.push({iii.first + x[ii.first] - x[(*grab)], {(*grab), ii.second}});
}
}
}
if(d[g].find(0) == d[g].end()) return -1;
return d[g][0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9816 KB |
Output is correct |
2 |
Correct |
3 ms |
9820 KB |
Output is correct |
3 |
Incorrect |
2 ms |
9840 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9816 KB |
Output is correct |
2 |
Correct |
2 ms |
9840 KB |
Output is correct |
3 |
Runtime error |
44 ms |
29888 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
60 ms |
23084 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
60 ms |
23084 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9816 KB |
Output is correct |
2 |
Correct |
3 ms |
9820 KB |
Output is correct |
3 |
Incorrect |
2 ms |
9840 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |