답안 #823823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
823823 2023-08-13T07:43:11 Z vjudge1 Sky Walking (IOI19_walk) C++17
24 / 100
2611 ms 418068 KB
#include<bits/stdc++.h>
#include "walk.h"

using namespace std;
using ll = long long;
int n, m;

const int N = 1e5 + 10;
const int M = 2e6 + 10;
const ll INF = 1e15;

vector<pair<int, ll>> G[M];

vector<int> in[N];
int inx[N];

vector<int> cities[N];


long long min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int s, int g) {
	n = (int)x.size(), m = (int)y.size();
	// first = height, second = type, third = index
	vector<pair<int, pair<int, int>>> ord;	
	for(int i = 0; i < n; i++) 
		ord.push_back({h[i], {1, i}});
	for(int i = 0; i < m; i++) 
		ord.push_back({y[i], {0, i}});
	
	sort(ord.rbegin(), ord.rend());
	set<int> lux;
	for(auto cur : ord) {
		auto [type, inx] = cur.second;
		if(type) 
			lux.insert(inx);
		else {
			int x = l[inx] - 1;
			while(*(--lux.end()) > x) {
				x = *lux.upper_bound(x);
				if(x > r[inx]) break;
				in[x].push_back(y[inx]);
				cities[inx].push_back(x);
			}
			
		}
	}

	for(int i = 0; i < n; i++) {
		in[i].push_back(0);
		sort(in[i].begin(), in[i].end());
		if(i) inx[i] = inx[i - 1] + (int)in[i - 1].size();
		for(int r = 0; r < (int)in[i].size() - 1; r++) {
			G[inx[i] + r].push_back({inx[i] + r + 1, in[i][r + 1] - in[i][r]});
			G[inx[i] + r + 1].push_back({inx[i] + r, in[i][r + 1] - in[i][r]});
		}
	}
	// for(int i = 0; i < n; i++) {
	// 	cout << "cur: " << i << '\n';
	// 	cout << '[';
	// 	for(int t : in[i]) 
	// 		cout << t << " ";
	// 	cout << ']';
	// 	cout << '\n';
	// }
	for(int i = 0; i < m; i++) {
		for(int z = 0; z < (int)cities[i].size() - 1; z++) {
			int st = cities[i][z], next = cities[i][z + 1];
			int pos1 = find(in[st].begin(), in[st].end(), y[i]) - in[st].begin();
			int pos2 = find(in[next].begin(), in[next].end(), y[i]) - in[next].begin();
			G[inx[st] + pos1].push_back({inx[next] + pos2, x[next] - x[st]});
			G[inx[next] + pos2].push_back({inx[st] + pos1, x[next] - x[st]});
		}
	}
	int T = inx[n - 1] + (int)in[n - 1].size();

	vector<ll> dist(T, INF);
	dist[inx[g]] = 0;
	set<pair<ll, int>> st;
	for(int i = 0; i < T; i++) {
		st.insert({dist[i], i});
	}
	while(!st.empty()) {
		int s = st.begin()->second;
		st.erase(st.begin());
		for(auto [to, w] : G[s]) {
			if(dist[to] > dist[s] + w) {
				st.erase({dist[to], to});
				dist[to] = dist[s] + w;
				st.insert({dist[to], to});
			}
		}
	}
	int fin = inx[s];
	if(dist[fin] == INF) return -1;
	return dist[fin];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 51924 KB Output is correct
2 Correct 26 ms 51928 KB Output is correct
3 Correct 27 ms 51932 KB Output is correct
4 Correct 26 ms 51916 KB Output is correct
5 Correct 28 ms 51972 KB Output is correct
6 Correct 27 ms 52052 KB Output is correct
7 Correct 27 ms 51984 KB Output is correct
8 Correct 27 ms 51988 KB Output is correct
9 Correct 26 ms 51956 KB Output is correct
10 Correct 27 ms 52036 KB Output is correct
11 Correct 26 ms 52000 KB Output is correct
12 Correct 27 ms 51920 KB Output is correct
13 Correct 26 ms 51928 KB Output is correct
14 Correct 26 ms 51968 KB Output is correct
15 Correct 25 ms 51952 KB Output is correct
16 Correct 26 ms 51984 KB Output is correct
17 Correct 26 ms 52068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 51892 KB Output is correct
2 Correct 27 ms 51972 KB Output is correct
3 Correct 1204 ms 178396 KB Output is correct
4 Correct 1062 ms 195436 KB Output is correct
5 Correct 645 ms 176552 KB Output is correct
6 Correct 585 ms 163192 KB Output is correct
7 Correct 655 ms 176792 KB Output is correct
8 Correct 1561 ms 212516 KB Output is correct
9 Correct 897 ms 174028 KB Output is correct
10 Correct 1519 ms 247184 KB Output is correct
11 Correct 549 ms 123840 KB Output is correct
12 Correct 414 ms 109344 KB Output is correct
13 Correct 1330 ms 224376 KB Output is correct
14 Correct 334 ms 107344 KB Output is correct
15 Correct 383 ms 112688 KB Output is correct
16 Correct 378 ms 111796 KB Output is correct
17 Correct 368 ms 109736 KB Output is correct
18 Correct 2611 ms 111712 KB Output is correct
19 Correct 39 ms 54872 KB Output is correct
20 Correct 146 ms 81380 KB Output is correct
21 Correct 343 ms 107304 KB Output is correct
22 Correct 373 ms 112492 KB Output is correct
23 Correct 809 ms 118472 KB Output is correct
24 Correct 368 ms 111192 KB Output is correct
25 Correct 387 ms 109804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 74316 KB Output is correct
2 Runtime error 639 ms 418068 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 74316 KB Output is correct
2 Runtime error 639 ms 418068 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 51924 KB Output is correct
2 Correct 26 ms 51928 KB Output is correct
3 Correct 27 ms 51932 KB Output is correct
4 Correct 26 ms 51916 KB Output is correct
5 Correct 28 ms 51972 KB Output is correct
6 Correct 27 ms 52052 KB Output is correct
7 Correct 27 ms 51984 KB Output is correct
8 Correct 27 ms 51988 KB Output is correct
9 Correct 26 ms 51956 KB Output is correct
10 Correct 27 ms 52036 KB Output is correct
11 Correct 26 ms 52000 KB Output is correct
12 Correct 27 ms 51920 KB Output is correct
13 Correct 26 ms 51928 KB Output is correct
14 Correct 26 ms 51968 KB Output is correct
15 Correct 25 ms 51952 KB Output is correct
16 Correct 26 ms 51984 KB Output is correct
17 Correct 26 ms 52068 KB Output is correct
18 Correct 26 ms 51892 KB Output is correct
19 Correct 27 ms 51972 KB Output is correct
20 Correct 1204 ms 178396 KB Output is correct
21 Correct 1062 ms 195436 KB Output is correct
22 Correct 645 ms 176552 KB Output is correct
23 Correct 585 ms 163192 KB Output is correct
24 Correct 655 ms 176792 KB Output is correct
25 Correct 1561 ms 212516 KB Output is correct
26 Correct 897 ms 174028 KB Output is correct
27 Correct 1519 ms 247184 KB Output is correct
28 Correct 549 ms 123840 KB Output is correct
29 Correct 414 ms 109344 KB Output is correct
30 Correct 1330 ms 224376 KB Output is correct
31 Correct 334 ms 107344 KB Output is correct
32 Correct 383 ms 112688 KB Output is correct
33 Correct 378 ms 111796 KB Output is correct
34 Correct 368 ms 109736 KB Output is correct
35 Correct 2611 ms 111712 KB Output is correct
36 Correct 39 ms 54872 KB Output is correct
37 Correct 146 ms 81380 KB Output is correct
38 Correct 343 ms 107304 KB Output is correct
39 Correct 373 ms 112492 KB Output is correct
40 Correct 809 ms 118472 KB Output is correct
41 Correct 368 ms 111192 KB Output is correct
42 Correct 387 ms 109804 KB Output is correct
43 Correct 137 ms 74316 KB Output is correct
44 Runtime error 639 ms 418068 KB Execution killed with signal 11
45 Halted 0 ms 0 KB -