Submission #417269

# Submission time Handle Problem Language Result Execution time Memory
417269 2021-06-03T14:09:36 Z Mlxa Sky Walking (IOI19_walk) C++14
10 / 100
4000 ms 371240 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#include "walk.h"

namespace my {
const int N = 2e6 + 10;

int ff = 0;
vector<pair<int, int>> g[N];
vector<pair<int, int>> ys[N];

void edge(int v, int u, int w) {
	g[v].emplace_back(u, w);
	g[u].emplace_back(v, w);
}

using T = pair<ll, int>;
const ll INF = 1e18;
priority_queue<T, vector<T>, greater<T>> q;
ll dst[N];
int ground[N];
}

ll min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int st, int fi) {
	using namespace my;
	for (int i = 0; i < (int)y.size(); ++i) {
		int lst = -1, lv = -1;
		for (int j = l[i]; j <= r[i]; ++j) {
			if (h[j] < y[i]) {
				continue;
			}
			int v = ff++;
			ys[j].emplace_back(y[i], v);
			if (lst != -1) {
				edge(v, lv, abs(x[lst] - x[j]));
			}
			lst = j;
			lv = v;
		}
	}
	for (int i = 0; i < (int)x.size(); ++i) {
		ground[i] = ff++;
		sort(all(ys[i]));
		int ly = 0, lv = ground[i];
		for (auto cur : ys[i]) {
			edge(cur.y, lv, abs(cur.x - ly));
			tie(ly, lv) = cur;
		}
	}

	int from = ground[st], to = ground[fi];
	fill_n(dst, N, INF);
	dst[from] = 0;
	q.emplace(dst[from], from);
	while (q.size()) {
		ll d, w;
		int v, u;
		tie(d, v) = q.top(); q.pop();
		if (d != dst[v]) {
			continue;
		}
		for (auto e : g[v]) {
			u = e.x, w = e.y;
			if (dst[u] > dst[v] + w) {
				dst[u] = dst[v] + w;
				q.emplace(dst[u], u);
			}
		}
	}
	if (dst[to] > INF / 2) {
		return -1;
	}
	return dst[to];
}

#ifdef LC
#include "grader.cpp"
#endif
# Verdict Execution time Memory Grader output
1 Correct 58 ms 109764 KB Output is correct
2 Correct 57 ms 109796 KB Output is correct
3 Correct 58 ms 109828 KB Output is correct
4 Correct 58 ms 109804 KB Output is correct
5 Correct 56 ms 109892 KB Output is correct
6 Correct 70 ms 109816 KB Output is correct
7 Correct 60 ms 109884 KB Output is correct
8 Correct 56 ms 109892 KB Output is correct
9 Correct 56 ms 109812 KB Output is correct
10 Correct 56 ms 109852 KB Output is correct
11 Correct 62 ms 109880 KB Output is correct
12 Correct 59 ms 109820 KB Output is correct
13 Correct 63 ms 109872 KB Output is correct
14 Correct 61 ms 109864 KB Output is correct
15 Correct 60 ms 109848 KB Output is correct
16 Correct 58 ms 109856 KB Output is correct
17 Correct 59 ms 109904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 109876 KB Output is correct
2 Correct 60 ms 109776 KB Output is correct
3 Correct 675 ms 158016 KB Output is correct
4 Correct 663 ms 163444 KB Output is correct
5 Correct 471 ms 156644 KB Output is correct
6 Correct 1242 ms 151840 KB Output is correct
7 Correct 467 ms 156688 KB Output is correct
8 Correct 823 ms 169556 KB Output is correct
9 Correct 510 ms 155972 KB Output is correct
10 Correct 981 ms 181816 KB Output is correct
11 Correct 428 ms 137676 KB Output is correct
12 Correct 275 ms 129064 KB Output is correct
13 Correct 891 ms 174964 KB Output is correct
14 Execution timed out 4054 ms 107592 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 131 ms 119064 KB Output is correct
2 Runtime error 492 ms 371240 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 131 ms 119064 KB Output is correct
2 Runtime error 492 ms 371240 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 58 ms 109764 KB Output is correct
2 Correct 57 ms 109796 KB Output is correct
3 Correct 58 ms 109828 KB Output is correct
4 Correct 58 ms 109804 KB Output is correct
5 Correct 56 ms 109892 KB Output is correct
6 Correct 70 ms 109816 KB Output is correct
7 Correct 60 ms 109884 KB Output is correct
8 Correct 56 ms 109892 KB Output is correct
9 Correct 56 ms 109812 KB Output is correct
10 Correct 56 ms 109852 KB Output is correct
11 Correct 62 ms 109880 KB Output is correct
12 Correct 59 ms 109820 KB Output is correct
13 Correct 63 ms 109872 KB Output is correct
14 Correct 61 ms 109864 KB Output is correct
15 Correct 60 ms 109848 KB Output is correct
16 Correct 58 ms 109856 KB Output is correct
17 Correct 59 ms 109904 KB Output is correct
18 Correct 62 ms 109876 KB Output is correct
19 Correct 60 ms 109776 KB Output is correct
20 Correct 675 ms 158016 KB Output is correct
21 Correct 663 ms 163444 KB Output is correct
22 Correct 471 ms 156644 KB Output is correct
23 Correct 1242 ms 151840 KB Output is correct
24 Correct 467 ms 156688 KB Output is correct
25 Correct 823 ms 169556 KB Output is correct
26 Correct 510 ms 155972 KB Output is correct
27 Correct 981 ms 181816 KB Output is correct
28 Correct 428 ms 137676 KB Output is correct
29 Correct 275 ms 129064 KB Output is correct
30 Correct 891 ms 174964 KB Output is correct
31 Execution timed out 4054 ms 107592 KB Time limit exceeded
32 Halted 0 ms 0 KB -