Submission #289668

# Submission time Handle Problem Language Result Execution time Memory
289668 2020-09-02T22:13:17 Z amiratou Sky Walking (IOI19_walk) C++14
24 / 100
1322 ms 236624 KB
#include "walk.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define sz(x) (int)x.size()
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> ii;
const int MX = (int)(1e5+5);
const ll INF = (ll)(1e18);

vector<ii> adj[MX],VEC[1200005];
ll dist[1200005];

ll min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int s, int g) {
	int n=sz(x);
	int idx=n;
	vector<pair<ii,int > >vec;
	for (int i = 0; i < n; ++i)
		vec.pb({{h[i],1},i});
	for (int i = 0; i < sz(l); ++i)
		vec.pb({{y[i],0},i});
	sort(vec.begin(),vec.end(),greater<pair<ii,int> > ());
	set<int> alive;
	for (int i = 0; i < sz(vec); ++i)
	{
		if(vec[i].fi.se)alive.insert(vec[i].se);
		else{
			auto it=alive.find(l[vec[i].se]);
			vector<ii> G;
			while(it!=alive.end() && (*it)<=r[vec[i].se]){
				adj[*it].pb({vec[i].fi.fi,idx});
				G.pb({idx,x[*it]}),idx++;
				it++;
			}
			for (int j = 0; j < sz(G)-1; ++j)
			{
				//cerr<<G[j].fi<<","<<G[j+1].fi<<" w : "<<G[j+1].se-G[j].se<<"\n";
				VEC[G[j].fi].pb({G[j+1].fi,G[j+1].se-G[j].se});
				VEC[G[j+1].fi].pb({G[j].fi,G[j+1].se-G[j].se});
			}

		}
	}
	for (int i = 0; i < n; ++i)
	{
		adj[i].pb({0,i});
		for (int j = sz(adj[i])-1; j >= 1; j--)
		{
			//cerr<<adj[i][j].se<<","<<adj[i][j-1].se<<" w : "<<adj[i][j-1].fi-adj[i][j].fi<<"\n";
			VEC[adj[i][j].se].pb({adj[i][j-1].se,adj[i][j-1].fi-adj[i][j].fi});
			VEC[adj[i][j-1].se].pb({adj[i][j].se,adj[i][j-1].fi-adj[i][j].fi});
		}
	}
	priority_queue<ii,vector<ii>,greater<ii> > pq;
	for (int i = 0; i < idx; ++i)
		dist[i]=INF;
	dist[s]=0;
	pq.push({0,s});
	while(!pq.empty()){
		ii f=pq.top();
		pq.pop();
		if(dist[f.se]!=f.fi)continue;
		for(auto it:VEC[f.se])
			if(dist[it.fi]>(f.fi+it.se)){
				dist[it.fi]=f.fi+it.se;
				pq.push({dist[it.fi],it.fi});
			}
	}
	if(dist[g]==INF)return -1;
	return dist[g];	
}
# Verdict Execution time Memory Grader output
1 Correct 21 ms 30848 KB Output is correct
2 Correct 21 ms 30848 KB Output is correct
3 Correct 21 ms 30848 KB Output is correct
4 Correct 21 ms 30848 KB Output is correct
5 Correct 21 ms 30976 KB Output is correct
6 Correct 21 ms 30976 KB Output is correct
7 Correct 21 ms 30976 KB Output is correct
8 Correct 21 ms 30848 KB Output is correct
9 Correct 21 ms 30848 KB Output is correct
10 Correct 21 ms 30976 KB Output is correct
11 Correct 21 ms 30840 KB Output is correct
12 Correct 21 ms 30848 KB Output is correct
13 Correct 21 ms 30848 KB Output is correct
14 Correct 21 ms 30848 KB Output is correct
15 Correct 21 ms 30848 KB Output is correct
16 Correct 21 ms 30848 KB Output is correct
17 Correct 22 ms 30976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 30848 KB Output is correct
2 Correct 22 ms 30848 KB Output is correct
3 Correct 795 ms 121324 KB Output is correct
4 Correct 1014 ms 137960 KB Output is correct
5 Correct 683 ms 123552 KB Output is correct
6 Correct 583 ms 114140 KB Output is correct
7 Correct 666 ms 123612 KB Output is correct
8 Correct 969 ms 143080 KB Output is correct
9 Correct 764 ms 121488 KB Output is correct
10 Correct 1322 ms 171112 KB Output is correct
11 Correct 556 ms 85468 KB Output is correct
12 Correct 459 ms 77148 KB Output is correct
13 Correct 1164 ms 156768 KB Output is correct
14 Correct 312 ms 74716 KB Output is correct
15 Correct 348 ms 76504 KB Output is correct
16 Correct 365 ms 75356 KB Output is correct
17 Correct 351 ms 74332 KB Output is correct
18 Correct 218 ms 77788 KB Output is correct
19 Correct 32 ms 33024 KB Output is correct
20 Correct 153 ms 53096 KB Output is correct
21 Correct 347 ms 71004 KB Output is correct
22 Correct 401 ms 76256 KB Output is correct
23 Correct 325 ms 84828 KB Output is correct
24 Correct 367 ms 75356 KB Output is correct
25 Correct 366 ms 73948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 144 ms 47728 KB Output is correct
2 Runtime error 453 ms 236624 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 144 ms 47728 KB Output is correct
2 Runtime error 453 ms 236624 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 30848 KB Output is correct
2 Correct 21 ms 30848 KB Output is correct
3 Correct 21 ms 30848 KB Output is correct
4 Correct 21 ms 30848 KB Output is correct
5 Correct 21 ms 30976 KB Output is correct
6 Correct 21 ms 30976 KB Output is correct
7 Correct 21 ms 30976 KB Output is correct
8 Correct 21 ms 30848 KB Output is correct
9 Correct 21 ms 30848 KB Output is correct
10 Correct 21 ms 30976 KB Output is correct
11 Correct 21 ms 30840 KB Output is correct
12 Correct 21 ms 30848 KB Output is correct
13 Correct 21 ms 30848 KB Output is correct
14 Correct 21 ms 30848 KB Output is correct
15 Correct 21 ms 30848 KB Output is correct
16 Correct 21 ms 30848 KB Output is correct
17 Correct 22 ms 30976 KB Output is correct
18 Correct 22 ms 30848 KB Output is correct
19 Correct 22 ms 30848 KB Output is correct
20 Correct 795 ms 121324 KB Output is correct
21 Correct 1014 ms 137960 KB Output is correct
22 Correct 683 ms 123552 KB Output is correct
23 Correct 583 ms 114140 KB Output is correct
24 Correct 666 ms 123612 KB Output is correct
25 Correct 969 ms 143080 KB Output is correct
26 Correct 764 ms 121488 KB Output is correct
27 Correct 1322 ms 171112 KB Output is correct
28 Correct 556 ms 85468 KB Output is correct
29 Correct 459 ms 77148 KB Output is correct
30 Correct 1164 ms 156768 KB Output is correct
31 Correct 312 ms 74716 KB Output is correct
32 Correct 348 ms 76504 KB Output is correct
33 Correct 365 ms 75356 KB Output is correct
34 Correct 351 ms 74332 KB Output is correct
35 Correct 218 ms 77788 KB Output is correct
36 Correct 32 ms 33024 KB Output is correct
37 Correct 153 ms 53096 KB Output is correct
38 Correct 347 ms 71004 KB Output is correct
39 Correct 401 ms 76256 KB Output is correct
40 Correct 325 ms 84828 KB Output is correct
41 Correct 367 ms 75356 KB Output is correct
42 Correct 366 ms 73948 KB Output is correct
43 Correct 144 ms 47728 KB Output is correct
44 Runtime error 453 ms 236624 KB Execution killed with signal 11
45 Halted 0 ms 0 KB -