답안 #737365

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
737365 2023-05-07T05:52:15 Z bobthebuilder Sky Walking (IOI19_walk) C++17
57 / 100
915 ms 600536 KB
#include "walk.h"
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define lowb(x) (x&(-x))
#define ALL(_x) _x.begin(),_x.end()
#define pii pair<ll,int>
#define f first
#define s second
#define SORT_UNIQUE(x) sort(ALL(x)),x.erase(unique(ALL(x)),x.end())
#define ll long long
const ll INF64=4e18;
const int maxn=2e6+5;
vector<pii> gr[maxn];
void add(int a,int b,int w){
	gr[a].pb({b,w}),gr[b].pb({a,w});
}
vector<pii> pts[maxn];
ll dist[maxn];
long long min_distance(std::vector<int> xx, std::vector<int> h, std::vector<int> l, std::vector<int> r, std::vector<int> y, int s, int g) {
	int n=sz(xx),m=sz(l);
	vector<pii> v;
	REP(i,n){
		v.pb({h[i],i});
	}
	vector<pii> vv;
	sort(ALL(v));
	REP(i,m){
		vv.pb({y[i],i});
	}
	sort(ALL(vv));
	reverse(ALL(vv)),reverse(ALL(v));
	int cur=0;
	set<int> ss;
	int p=0;
	for(auto x:vv){
		while(p<n and v[p].f>=x.f){
			ss.insert(v[p].s);
			++p;
		}
		int a=l[x.s],b=r[x.s];
		ss.insert(a),ss.insert(b);
		auto it=ss.lower_bound(a);
		int pp=-1;
		vector<int> del;
		while(it!=ss.end() and (*it)<=b){
			int z=(*it);
			if(sz(pts[z])){
			auto pv=pts[z].back();
			add(pv.s,cur,pv.f-x.f);
			}
			pts[z].pb({x.f,cur});
			if(pp!=-1) add(cur-1,cur,xx[z]-xx[pp]);
			pp=z;
			++cur;
			if(z!=a and z!=b){
				del.pb(z);
			}
			++it;
		}
		if(s==0 and g==n-1) for(int x:del) ss.erase(x);
	}
	for(int z:{s,g}){
		if(!sz(pts[z])){
			return -1;
		}
		auto pv=pts[z].back();
		add(pv.s,cur++,pv.f);
	}
	REP(i,cur) dist[i]=INF64;
	priority_queue<pii,vector<pii>,greater<pii>> pq;
	pq.push({0,cur-2});
	dist[cur-2]=0;
	while(sz(pq)){
		int z=pq.top().s;
		if(pq.top().f>dist[z]){
			pq.pop();
			continue;
		}
		pq.pop();
		for(auto x:gr[z]){
			if(dist[x.f]>dist[z]+x.s){
				dist[x.f]=dist[z]+x.s;
				pq.push({dist[x.f],x.f});
			}
		}
	}
	if(dist[cur-1]==INF64) dist[cur-1]=-1;
	return dist[cur-1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 94156 KB Output is correct
2 Correct 45 ms 94224 KB Output is correct
3 Correct 46 ms 94176 KB Output is correct
4 Correct 45 ms 94156 KB Output is correct
5 Correct 48 ms 94224 KB Output is correct
6 Correct 47 ms 94180 KB Output is correct
7 Correct 45 ms 94336 KB Output is correct
8 Correct 46 ms 94172 KB Output is correct
9 Correct 46 ms 94176 KB Output is correct
10 Correct 53 ms 94300 KB Output is correct
11 Correct 46 ms 94192 KB Output is correct
12 Correct 46 ms 94216 KB Output is correct
13 Correct 45 ms 94192 KB Output is correct
14 Correct 48 ms 94172 KB Output is correct
15 Correct 46 ms 94176 KB Output is correct
16 Correct 46 ms 94224 KB Output is correct
17 Correct 45 ms 94164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 94168 KB Output is correct
2 Correct 45 ms 94128 KB Output is correct
3 Correct 565 ms 176364 KB Output is correct
4 Correct 776 ms 180352 KB Output is correct
5 Correct 492 ms 169148 KB Output is correct
6 Correct 464 ms 160188 KB Output is correct
7 Correct 499 ms 169120 KB Output is correct
8 Correct 654 ms 197160 KB Output is correct
9 Correct 569 ms 168264 KB Output is correct
10 Correct 915 ms 213964 KB Output is correct
11 Correct 391 ms 138072 KB Output is correct
12 Correct 333 ms 122292 KB Output is correct
13 Correct 643 ms 147676 KB Output is correct
14 Correct 242 ms 119960 KB Output is correct
15 Correct 289 ms 122752 KB Output is correct
16 Correct 262 ms 124472 KB Output is correct
17 Correct 252 ms 123660 KB Output is correct
18 Correct 160 ms 125008 KB Output is correct
19 Correct 55 ms 95656 KB Output is correct
20 Correct 124 ms 107652 KB Output is correct
21 Correct 298 ms 122856 KB Output is correct
22 Correct 292 ms 122764 KB Output is correct
23 Correct 233 ms 127132 KB Output is correct
24 Correct 268 ms 123116 KB Output is correct
25 Correct 285 ms 123280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 108636 KB Output is correct
2 Correct 293 ms 140508 KB Output is correct
3 Correct 365 ms 144148 KB Output is correct
4 Correct 568 ms 159548 KB Output is correct
5 Correct 597 ms 160244 KB Output is correct
6 Correct 556 ms 157832 KB Output is correct
7 Correct 367 ms 134084 KB Output is correct
8 Correct 308 ms 122348 KB Output is correct
9 Correct 532 ms 156292 KB Output is correct
10 Correct 309 ms 138388 KB Output is correct
11 Correct 69 ms 98220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 108636 KB Output is correct
2 Correct 293 ms 140508 KB Output is correct
3 Correct 365 ms 144148 KB Output is correct
4 Correct 568 ms 159548 KB Output is correct
5 Correct 597 ms 160244 KB Output is correct
6 Correct 556 ms 157832 KB Output is correct
7 Correct 367 ms 134084 KB Output is correct
8 Correct 308 ms 122348 KB Output is correct
9 Correct 532 ms 156292 KB Output is correct
10 Correct 309 ms 138388 KB Output is correct
11 Correct 69 ms 98220 KB Output is correct
12 Correct 381 ms 144140 KB Output is correct
13 Correct 407 ms 153668 KB Output is correct
14 Correct 562 ms 159928 KB Output is correct
15 Correct 561 ms 143996 KB Output is correct
16 Correct 615 ms 152204 KB Output is correct
17 Correct 636 ms 161824 KB Output is correct
18 Correct 509 ms 144112 KB Output is correct
19 Correct 428 ms 147728 KB Output is correct
20 Correct 348 ms 133928 KB Output is correct
21 Correct 132 ms 106656 KB Output is correct
22 Correct 345 ms 144736 KB Output is correct
23 Correct 366 ms 142236 KB Output is correct
24 Correct 311 ms 129588 KB Output is correct
25 Correct 371 ms 139456 KB Output is correct
26 Correct 240 ms 119744 KB Output is correct
27 Correct 567 ms 160256 KB Output is correct
28 Correct 468 ms 152812 KB Output is correct
29 Correct 566 ms 157916 KB Output is correct
30 Correct 372 ms 134424 KB Output is correct
31 Correct 568 ms 155888 KB Output is correct
32 Correct 317 ms 130948 KB Output is correct
33 Correct 299 ms 130204 KB Output is correct
34 Correct 256 ms 132456 KB Output is correct
35 Correct 305 ms 132752 KB Output is correct
36 Correct 318 ms 127640 KB Output is correct
37 Correct 281 ms 125248 KB Output is correct
38 Correct 295 ms 125580 KB Output is correct
39 Correct 234 ms 129684 KB Output is correct
40 Correct 280 ms 125880 KB Output is correct
41 Correct 291 ms 125572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 94156 KB Output is correct
2 Correct 45 ms 94224 KB Output is correct
3 Correct 46 ms 94176 KB Output is correct
4 Correct 45 ms 94156 KB Output is correct
5 Correct 48 ms 94224 KB Output is correct
6 Correct 47 ms 94180 KB Output is correct
7 Correct 45 ms 94336 KB Output is correct
8 Correct 46 ms 94172 KB Output is correct
9 Correct 46 ms 94176 KB Output is correct
10 Correct 53 ms 94300 KB Output is correct
11 Correct 46 ms 94192 KB Output is correct
12 Correct 46 ms 94216 KB Output is correct
13 Correct 45 ms 94192 KB Output is correct
14 Correct 48 ms 94172 KB Output is correct
15 Correct 46 ms 94176 KB Output is correct
16 Correct 46 ms 94224 KB Output is correct
17 Correct 45 ms 94164 KB Output is correct
18 Correct 47 ms 94168 KB Output is correct
19 Correct 45 ms 94128 KB Output is correct
20 Correct 565 ms 176364 KB Output is correct
21 Correct 776 ms 180352 KB Output is correct
22 Correct 492 ms 169148 KB Output is correct
23 Correct 464 ms 160188 KB Output is correct
24 Correct 499 ms 169120 KB Output is correct
25 Correct 654 ms 197160 KB Output is correct
26 Correct 569 ms 168264 KB Output is correct
27 Correct 915 ms 213964 KB Output is correct
28 Correct 391 ms 138072 KB Output is correct
29 Correct 333 ms 122292 KB Output is correct
30 Correct 643 ms 147676 KB Output is correct
31 Correct 242 ms 119960 KB Output is correct
32 Correct 289 ms 122752 KB Output is correct
33 Correct 262 ms 124472 KB Output is correct
34 Correct 252 ms 123660 KB Output is correct
35 Correct 160 ms 125008 KB Output is correct
36 Correct 55 ms 95656 KB Output is correct
37 Correct 124 ms 107652 KB Output is correct
38 Correct 298 ms 122856 KB Output is correct
39 Correct 292 ms 122764 KB Output is correct
40 Correct 233 ms 127132 KB Output is correct
41 Correct 268 ms 123116 KB Output is correct
42 Correct 285 ms 123280 KB Output is correct
43 Correct 130 ms 108636 KB Output is correct
44 Correct 293 ms 140508 KB Output is correct
45 Correct 365 ms 144148 KB Output is correct
46 Correct 568 ms 159548 KB Output is correct
47 Correct 597 ms 160244 KB Output is correct
48 Correct 556 ms 157832 KB Output is correct
49 Correct 367 ms 134084 KB Output is correct
50 Correct 308 ms 122348 KB Output is correct
51 Correct 532 ms 156292 KB Output is correct
52 Correct 309 ms 138388 KB Output is correct
53 Correct 69 ms 98220 KB Output is correct
54 Correct 381 ms 144140 KB Output is correct
55 Correct 407 ms 153668 KB Output is correct
56 Correct 562 ms 159928 KB Output is correct
57 Correct 561 ms 143996 KB Output is correct
58 Correct 615 ms 152204 KB Output is correct
59 Correct 636 ms 161824 KB Output is correct
60 Correct 509 ms 144112 KB Output is correct
61 Correct 428 ms 147728 KB Output is correct
62 Correct 348 ms 133928 KB Output is correct
63 Correct 132 ms 106656 KB Output is correct
64 Correct 345 ms 144736 KB Output is correct
65 Correct 366 ms 142236 KB Output is correct
66 Correct 311 ms 129588 KB Output is correct
67 Correct 371 ms 139456 KB Output is correct
68 Correct 240 ms 119744 KB Output is correct
69 Correct 567 ms 160256 KB Output is correct
70 Correct 468 ms 152812 KB Output is correct
71 Correct 566 ms 157916 KB Output is correct
72 Correct 372 ms 134424 KB Output is correct
73 Correct 568 ms 155888 KB Output is correct
74 Correct 317 ms 130948 KB Output is correct
75 Correct 299 ms 130204 KB Output is correct
76 Correct 256 ms 132456 KB Output is correct
77 Correct 305 ms 132752 KB Output is correct
78 Correct 318 ms 127640 KB Output is correct
79 Correct 281 ms 125248 KB Output is correct
80 Correct 295 ms 125580 KB Output is correct
81 Correct 234 ms 129684 KB Output is correct
82 Correct 280 ms 125880 KB Output is correct
83 Correct 291 ms 125572 KB Output is correct
84 Correct 120 ms 106560 KB Output is correct
85 Runtime error 719 ms 600536 KB Execution killed with signal 11
86 Halted 0 ms 0 KB -