답안 #1058332

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1058332 2024-08-14T09:24:04 Z Unforgettablepl Sky Walking (IOI19_walk) C++17
24 / 100
1466 ms 1048576 KB
#include "walk.h"
#include <bits/stdc++.h>
using namespace std;

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();
	int m = l.size();
	vector<vector<pair<int,int>>> points(n);
	vector<vector<pair<int,int>>> adj;
	int S = 0;
	vector<tuple<int,int,int>> skywalks;
	for(int i=0;i<m;i++)skywalks.emplace_back(y[i],l[i],r[i]);
	sort(skywalks.rbegin(), skywalks.rend());
	auto add_point = [&](int x,int h) {
		adj.emplace_back();
		if(!points[x].empty())adj[S].emplace_back(points[x].back().first,points[x].back().second-h);
		if(!points[x].empty())adj[points[x].back().first].emplace_back(S,points[x].back().second-h);
		points[x].emplace_back(S,h);
		return S++;
	};
	vector<pair<int,int>> sorted_buildings;
	for(int i=0;i<n;i++)sorted_buildings.emplace_back(h[i],i);
	sort(sorted_buildings.rbegin(),sorted_buildings.rend());
	auto iterb = sorted_buildings.begin();
	set<int> active;
	for(int i=0;i<m;i++){
		auto [height,left,right] = skywalks[i];
		while(iterb!=sorted_buildings.end() and iterb->first>=height)active.insert((iterb++)->second);
		auto last_point = add_point(left,height);
		auto last_x = x[left];
		for(auto iter=active.upper_bound(left);true;iter++){
			int j = *iter;
			auto curr_point = add_point(j,height);
			adj[curr_point].emplace_back(last_point,x[j]-last_x);
			adj[last_point].emplace_back(curr_point,x[j]-last_x);
			last_point=curr_point;
			last_x=x[j];
			if(*iter==right)break;
		}
	}
	for(int i=0;i<n;i++)add_point(i,0);
	priority_queue<pair<long long,int>> q;
	vector<bool> visited(S);
	s = points[s].back().first;
	g = points[g].back().first;
	q.emplace(0,s);
	while(!q.empty()) {
		auto [dist,idx] = q.top();q.pop();dist=-dist;
		if(visited[idx])continue;
		visited[idx]=true;
		if(idx==g)return dist;
		for(auto&[v,c]:adj[idx])if(!visited[v])q.emplace(-dist-c,v);
	}
	return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 432 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 436 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 197 ms 67172 KB Output is correct
4 Correct 429 ms 83372 KB Output is correct
5 Correct 244 ms 72880 KB Output is correct
6 Correct 219 ms 72116 KB Output is correct
7 Correct 284 ms 72364 KB Output is correct
8 Correct 237 ms 82376 KB Output is correct
9 Correct 286 ms 71040 KB Output is correct
10 Correct 520 ms 126968 KB Output is correct
11 Correct 153 ms 43196 KB Output is correct
12 Correct 146 ms 44984 KB Output is correct
13 Correct 500 ms 95728 KB Output is correct
14 Correct 104 ms 43452 KB Output is correct
15 Correct 95 ms 42688 KB Output is correct
16 Correct 99 ms 42684 KB Output is correct
17 Correct 92 ms 40896 KB Output is correct
18 Correct 81 ms 37056 KB Output is correct
19 Correct 4 ms 2452 KB Output is correct
20 Correct 41 ms 23436 KB Output is correct
21 Correct 84 ms 41412 KB Output is correct
22 Correct 87 ms 42688 KB Output is correct
23 Correct 119 ms 48820 KB Output is correct
24 Correct 88 ms 43200 KB Output is correct
25 Correct 91 ms 41480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 13520 KB Output is correct
2 Correct 1132 ms 442056 KB Output is correct
3 Runtime error 1466 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 13520 KB Output is correct
2 Correct 1132 ms 442056 KB Output is correct
3 Runtime error 1466 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 432 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 436 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 197 ms 67172 KB Output is correct
21 Correct 429 ms 83372 KB Output is correct
22 Correct 244 ms 72880 KB Output is correct
23 Correct 219 ms 72116 KB Output is correct
24 Correct 284 ms 72364 KB Output is correct
25 Correct 237 ms 82376 KB Output is correct
26 Correct 286 ms 71040 KB Output is correct
27 Correct 520 ms 126968 KB Output is correct
28 Correct 153 ms 43196 KB Output is correct
29 Correct 146 ms 44984 KB Output is correct
30 Correct 500 ms 95728 KB Output is correct
31 Correct 104 ms 43452 KB Output is correct
32 Correct 95 ms 42688 KB Output is correct
33 Correct 99 ms 42684 KB Output is correct
34 Correct 92 ms 40896 KB Output is correct
35 Correct 81 ms 37056 KB Output is correct
36 Correct 4 ms 2452 KB Output is correct
37 Correct 41 ms 23436 KB Output is correct
38 Correct 84 ms 41412 KB Output is correct
39 Correct 87 ms 42688 KB Output is correct
40 Correct 119 ms 48820 KB Output is correct
41 Correct 88 ms 43200 KB Output is correct
42 Correct 91 ms 41480 KB Output is correct
43 Correct 29 ms 13520 KB Output is correct
44 Correct 1132 ms 442056 KB Output is correct
45 Runtime error 1466 ms 1048576 KB Execution killed with signal 9
46 Halted 0 ms 0 KB -