답안 #294116

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
294116 2020-09-08T15:36:52 Z PeppaPig Sky Walking (IOI19_walk) C++14
33 / 100
390 ms 67948 KB
#include "walk.h"
#include <bits/stdc++.h>

#define long long long
#define pii pair<long, long>
#define x first
#define y second

using namespace std;

const int N = 1.2e6 + 5;

int n, m;
int pos[N];
long dp[N];
vector<pii> g[N];

long min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int su, int eu) {
	n = (int)x.size(), m = (int)l.size();
	iota(pos, pos + N, 0);

	sort(pos, pos + m, [&](int a, int b) {
		return l[a] < l[b];
	});	

	priority_queue<pii, vector<pii>, greater<pii> > rem, Q;
	set<pii> active;
	for(int _ = 0; _ < m; _++) {
		int i = pos[_];
		while(!rem.empty() && rem.top().x < l[i]) {
			active.erase(pii(y[rem.top().y], rem.top().y));
			rem.pop();
		}
		auto it = active.lower_bound(pii(y[i], -1e9));
		if(it != active.end()) {
			g[i].emplace_back(it->y, it->x - y[i]);
			g[it->y].emplace_back(i, it->x - y[i]);
		}
		if(it != active.begin()) {
			--it;
			g[i].emplace_back(it->y, y[i] - it->x);
			g[it->y].emplace_back(i, y[i] - it->x);
		}
		active.emplace(y[i], i), rem.emplace(r[i], i);
	}

	fill_n(dp, N, 1e18);
	for(int i = 0; i < m; i++) if(l[i] == 0)
		Q.emplace(dp[i] = y[i], i);	

	while(!Q.empty()) {
		pii u = Q.top(); Q.pop();
		if(dp[u.y] != u.x) continue;
		for(pii v : g[u.y]) if(u.x + v.y < dp[v.x])
			Q.emplace(dp[v.x] = u.x + v.y, v.x);
	}

	long ans = 1e18;
	for(int i = 0; i < m; i++) if(r[i] == n - 1)
		ans = min(ans, dp[i] + y[i]);
	
	return ans == 1e18 ? -1 : ans + x[eu] - x[su];
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 42624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 42616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 48376 KB Output is correct
2 Correct 262 ms 54904 KB Output is correct
3 Correct 277 ms 55032 KB Output is correct
4 Correct 307 ms 56440 KB Output is correct
5 Correct 327 ms 63920 KB Output is correct
6 Correct 390 ms 59244 KB Output is correct
7 Correct 140 ms 50296 KB Output is correct
8 Correct 153 ms 51192 KB Output is correct
9 Correct 363 ms 64152 KB Output is correct
10 Correct 237 ms 61836 KB Output is correct
11 Correct 45 ms 44152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 48376 KB Output is correct
2 Correct 262 ms 54904 KB Output is correct
3 Correct 277 ms 55032 KB Output is correct
4 Correct 307 ms 56440 KB Output is correct
5 Correct 327 ms 63920 KB Output is correct
6 Correct 390 ms 59244 KB Output is correct
7 Correct 140 ms 50296 KB Output is correct
8 Correct 153 ms 51192 KB Output is correct
9 Correct 363 ms 64152 KB Output is correct
10 Correct 237 ms 61836 KB Output is correct
11 Correct 45 ms 44152 KB Output is correct
12 Correct 271 ms 56952 KB Output is correct
13 Correct 278 ms 60280 KB Output is correct
14 Correct 349 ms 67948 KB Output is correct
15 Correct 260 ms 58740 KB Output is correct
16 Correct 287 ms 62016 KB Output is correct
17 Correct 259 ms 60912 KB Output is correct
18 Correct 240 ms 58604 KB Output is correct
19 Correct 274 ms 61800 KB Output is correct
20 Correct 155 ms 53240 KB Output is correct
21 Correct 66 ms 46328 KB Output is correct
22 Correct 213 ms 58104 KB Output is correct
23 Correct 226 ms 58360 KB Output is correct
24 Correct 208 ms 57712 KB Output is correct
25 Correct 200 ms 57380 KB Output is correct
26 Correct 202 ms 58352 KB Output is correct
27 Correct 350 ms 66792 KB Output is correct
28 Correct 215 ms 60152 KB Output is correct
29 Correct 376 ms 63084 KB Output is correct
30 Correct 144 ms 53496 KB Output is correct
31 Correct 383 ms 63980 KB Output is correct
32 Correct 200 ms 57840 KB Output is correct
33 Correct 199 ms 58608 KB Output is correct
34 Correct 209 ms 60400 KB Output is correct
35 Correct 215 ms 57848 KB Output is correct
36 Correct 156 ms 55960 KB Output is correct
37 Correct 153 ms 55928 KB Output is correct
38 Correct 177 ms 57584 KB Output is correct
39 Correct 209 ms 61164 KB Output is correct
40 Correct 175 ms 56824 KB Output is correct
41 Correct 146 ms 55416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 42624 KB Output isn't correct
2 Halted 0 ms 0 KB -