# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1048401 |
2024-08-08T07:20:52 Z |
Malix |
Sky Walking (IOI19_walk) |
C++14 |
|
2159 ms |
673620 KB |
#include "walk.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;
typedef vector<ll> li;
typedef vector<li> lii;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LSOne(s) ((s)&(-s))
ll INF=1e18+10;
int inf=1e9+10;
ll M=1e9+7;
int n,m;
vi st;
vi arr;
void build(int x,int l,int r){
if(l==r){
st[x]=arr[l];
return;
}
int m=(l+r)/2;
build(2*x,l,m);
build(2*x+1,m+1,r);
st[x]=max(st[2*x],st[2*x+1]);
}
int mx(int x,int l,int r,int a,int b){
if(a>b)return 0;
if(l==a&&r==b)return st[x];
int m=(l+r)/2;
return max(mx(2*x,l,m,a,min(b,m)),mx(2*x+1,m+1,r,max(a,m+1),b));
}
int solve(int h,int l,int r){
if(l==r)return l;
int m=(l+r)/2;
int k=mx(1,0,n-1,l,m);
if(k>=h)return solve(h,l,m);
else return solve(h,m+1,r);
}
long long min_distance(std::vector<int> x, std::vector<int> h, std::vector<int> l, std::vector<int> r, std::vector<int> y, int s, int g) {
n=x.size();m=l.size();
st.resize(4*n);
arr=h;
build(1,0,n-1);
map<int,pi> mp;
int k=0;
vector<pii> a(2e6);
vector<set<pi>> b(n);
REP(i,0,m){
int p=l[i];
mp[k]={l[i],y[i]};
b[l[i]].insert({y[i],k});
k++;
while(p<r[i]){
int t=solve(y[i],p+1,r[i]);
mp[k]={t,y[i]};
b[t].insert({y[i],k});
int dis=x[t]-x[p];
a[k].PB({k-1,dis});
a[k-1].PB({k,dis});
k++;
p=t;
}
}
int spos=s,epos=g;
REP(i,0,n){
if(i==s)spos=k;
if(i==g)epos=k;
mp[k]={i,0};
int c=0,d=k;
for(auto u:b[i]){
a[d].PB({u.S,u.F-c});
a[u.S].PB({d,u.F-c});
c=u.F;d=u.S;
}
k++;
}
vector<ll> dist(k+1,INF);
priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> pq;
pq.push({0,spos});dist[spos]=0;
while(!pq.empty()){
ll distance=pq.top().F;
int node=pq.top().S;
pq.pop();
if(dist[node]<distance)continue;
for(auto u:a[node]){
if(dist[u.F]<=distance+u.S)continue;
dist[u.F]=distance+u.S;
pq.push({dist[u.F],u.F});
}
}
if(dist[epos]==INF)return -1;
return dist[epos];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
47196 KB |
Output is correct |
2 |
Correct |
7 ms |
47160 KB |
Output is correct |
3 |
Correct |
7 ms |
47196 KB |
Output is correct |
4 |
Correct |
7 ms |
47196 KB |
Output is correct |
5 |
Correct |
8 ms |
47540 KB |
Output is correct |
6 |
Correct |
9 ms |
47452 KB |
Output is correct |
7 |
Correct |
9 ms |
47448 KB |
Output is correct |
8 |
Correct |
8 ms |
47452 KB |
Output is correct |
9 |
Correct |
8 ms |
47308 KB |
Output is correct |
10 |
Correct |
8 ms |
47452 KB |
Output is correct |
11 |
Correct |
8 ms |
47452 KB |
Output is correct |
12 |
Correct |
7 ms |
47364 KB |
Output is correct |
13 |
Correct |
8 ms |
47196 KB |
Output is correct |
14 |
Correct |
9 ms |
47196 KB |
Output is correct |
15 |
Correct |
10 ms |
47412 KB |
Output is correct |
16 |
Correct |
8 ms |
47196 KB |
Output is correct |
17 |
Correct |
8 ms |
47444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
47196 KB |
Output is correct |
2 |
Correct |
7 ms |
47352 KB |
Output is correct |
3 |
Correct |
1075 ms |
185844 KB |
Output is correct |
4 |
Correct |
927 ms |
202196 KB |
Output is correct |
5 |
Correct |
629 ms |
182460 KB |
Output is correct |
6 |
Correct |
525 ms |
166996 KB |
Output is correct |
7 |
Correct |
632 ms |
182472 KB |
Output is correct |
8 |
Correct |
1345 ms |
224988 KB |
Output is correct |
9 |
Correct |
681 ms |
179028 KB |
Output is correct |
10 |
Correct |
1322 ms |
260944 KB |
Output is correct |
11 |
Correct |
399 ms |
122704 KB |
Output is correct |
12 |
Correct |
201 ms |
103252 KB |
Output is correct |
13 |
Correct |
1060 ms |
235056 KB |
Output is correct |
14 |
Correct |
323 ms |
101196 KB |
Output is correct |
15 |
Correct |
329 ms |
102580 KB |
Output is correct |
16 |
Correct |
242 ms |
103780 KB |
Output is correct |
17 |
Correct |
228 ms |
101712 KB |
Output is correct |
18 |
Correct |
383 ms |
104132 KB |
Output is correct |
19 |
Correct |
18 ms |
50008 KB |
Output is correct |
20 |
Correct |
131 ms |
74068 KB |
Output is correct |
21 |
Correct |
179 ms |
99468 KB |
Output is correct |
22 |
Correct |
189 ms |
102496 KB |
Output is correct |
23 |
Correct |
445 ms |
114124 KB |
Output is correct |
24 |
Correct |
243 ms |
102484 KB |
Output is correct |
25 |
Correct |
212 ms |
101968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
69648 KB |
Output is correct |
2 |
Runtime error |
2159 ms |
673620 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
69648 KB |
Output is correct |
2 |
Runtime error |
2159 ms |
673620 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
47196 KB |
Output is correct |
2 |
Correct |
7 ms |
47160 KB |
Output is correct |
3 |
Correct |
7 ms |
47196 KB |
Output is correct |
4 |
Correct |
7 ms |
47196 KB |
Output is correct |
5 |
Correct |
8 ms |
47540 KB |
Output is correct |
6 |
Correct |
9 ms |
47452 KB |
Output is correct |
7 |
Correct |
9 ms |
47448 KB |
Output is correct |
8 |
Correct |
8 ms |
47452 KB |
Output is correct |
9 |
Correct |
8 ms |
47308 KB |
Output is correct |
10 |
Correct |
8 ms |
47452 KB |
Output is correct |
11 |
Correct |
8 ms |
47452 KB |
Output is correct |
12 |
Correct |
7 ms |
47364 KB |
Output is correct |
13 |
Correct |
8 ms |
47196 KB |
Output is correct |
14 |
Correct |
9 ms |
47196 KB |
Output is correct |
15 |
Correct |
10 ms |
47412 KB |
Output is correct |
16 |
Correct |
8 ms |
47196 KB |
Output is correct |
17 |
Correct |
8 ms |
47444 KB |
Output is correct |
18 |
Correct |
8 ms |
47196 KB |
Output is correct |
19 |
Correct |
7 ms |
47352 KB |
Output is correct |
20 |
Correct |
1075 ms |
185844 KB |
Output is correct |
21 |
Correct |
927 ms |
202196 KB |
Output is correct |
22 |
Correct |
629 ms |
182460 KB |
Output is correct |
23 |
Correct |
525 ms |
166996 KB |
Output is correct |
24 |
Correct |
632 ms |
182472 KB |
Output is correct |
25 |
Correct |
1345 ms |
224988 KB |
Output is correct |
26 |
Correct |
681 ms |
179028 KB |
Output is correct |
27 |
Correct |
1322 ms |
260944 KB |
Output is correct |
28 |
Correct |
399 ms |
122704 KB |
Output is correct |
29 |
Correct |
201 ms |
103252 KB |
Output is correct |
30 |
Correct |
1060 ms |
235056 KB |
Output is correct |
31 |
Correct |
323 ms |
101196 KB |
Output is correct |
32 |
Correct |
329 ms |
102580 KB |
Output is correct |
33 |
Correct |
242 ms |
103780 KB |
Output is correct |
34 |
Correct |
228 ms |
101712 KB |
Output is correct |
35 |
Correct |
383 ms |
104132 KB |
Output is correct |
36 |
Correct |
18 ms |
50008 KB |
Output is correct |
37 |
Correct |
131 ms |
74068 KB |
Output is correct |
38 |
Correct |
179 ms |
99468 KB |
Output is correct |
39 |
Correct |
189 ms |
102496 KB |
Output is correct |
40 |
Correct |
445 ms |
114124 KB |
Output is correct |
41 |
Correct |
243 ms |
102484 KB |
Output is correct |
42 |
Correct |
212 ms |
101968 KB |
Output is correct |
43 |
Correct |
114 ms |
69648 KB |
Output is correct |
44 |
Runtime error |
2159 ms |
673620 KB |
Execution killed with signal 11 |
45 |
Halted |
0 ms |
0 KB |
- |