Submission #422760

# Submission time Handle Problem Language Result Execution time Memory
422760 2021-06-10T11:53:29 Z KoD Sky Walking (IOI19_walk) C++17
15 / 100
294 ms 26276 KB
#include <bits/stdc++.h>
#include "walk.h"

using ll = long long;
template <class T> using Vec = std::vector<T>;

constexpr ll INF = std::numeric_limits<ll>::max() / 2;

ll min_distance(Vec<int> x, Vec<int> h, Vec<int> l, Vec<int> r, Vec<int> y, int s, int g) {
	const int n = (int) x.size();
	const int m = (int) y.size();
	if (s == 0 and g == n - 1) {
		Vec<Vec<int>> start(n), end(n);
		for (int i = 0; i < m; ++i) {
			start[l[i]].push_back(i);
			end[r[i]].push_back(i);
		}
		std::map<int, ll> map;
		std::multiset<int> alive;
		for (const auto i: start[0]) {
			map[y[i]] = y[i];
			alive.insert(y[i]);
		}
		for (int i = 1; i < n; ++i) {
			for (const auto j: start[i]) {
				if (alive.find(y[j]) == alive.end()) {
					auto itr = map.lower_bound(y[j]);	
					ll d = INF;
					if (itr != map.end() and h[i] >= itr -> first) {
						d = std::min(d, itr -> second + (itr -> first - y[j]));
					}
					if (itr != map.begin()) {
						--itr;
						d = std::min(d, itr -> second + (y[j] - itr -> first));
					}
					map.emplace(y[j], d);
				}
				alive.insert(y[j]);
			}
			if (i != n - 1) {
				for (const auto j: end[i]) {
					alive.erase(alive.find(y[j]));
					if (alive.find(y[j]) == alive.end()) {
						map.erase(y[j]);
					}
				}
			}
		}
		ll ret = INF;
		for (const auto [y, d]: map) {
			ret = std::min(ret, y + d);
		}
		return (ret == INF ? -1  : ret + (x[n - 1] - x[0]));
	}
	return -1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2944 KB Output is correct
2 Correct 145 ms 4364 KB Output is correct
3 Correct 153 ms 7408 KB Output is correct
4 Correct 220 ms 17448 KB Output is correct
5 Correct 294 ms 26276 KB Output is correct
6 Correct 282 ms 21776 KB Output is correct
7 Correct 95 ms 13608 KB Output is correct
8 Correct 149 ms 19128 KB Output is correct
9 Correct 270 ms 23348 KB Output is correct
10 Correct 165 ms 21292 KB Output is correct
11 Correct 13 ms 4128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2944 KB Output is correct
2 Correct 145 ms 4364 KB Output is correct
3 Correct 153 ms 7408 KB Output is correct
4 Correct 220 ms 17448 KB Output is correct
5 Correct 294 ms 26276 KB Output is correct
6 Correct 282 ms 21776 KB Output is correct
7 Correct 95 ms 13608 KB Output is correct
8 Correct 149 ms 19128 KB Output is correct
9 Correct 270 ms 23348 KB Output is correct
10 Correct 165 ms 21292 KB Output is correct
11 Correct 13 ms 4128 KB Output is correct
12 Correct 153 ms 7292 KB Output is correct
13 Correct 194 ms 17400 KB Output is correct
14 Correct 272 ms 26144 KB Output is correct
15 Correct 172 ms 17732 KB Output is correct
16 Correct 158 ms 17968 KB Output is correct
17 Correct 165 ms 17972 KB Output is correct
18 Correct 154 ms 17696 KB Output is correct
19 Correct 212 ms 17984 KB Output is correct
20 Correct 118 ms 13780 KB Output is correct
21 Correct 31 ms 8616 KB Output is correct
22 Correct 129 ms 14936 KB Output is correct
23 Correct 134 ms 15268 KB Output is correct
24 Correct 131 ms 17704 KB Output is correct
25 Correct 130 ms 15168 KB Output is correct
26 Correct 142 ms 21572 KB Output is correct
27 Correct 280 ms 24996 KB Output is correct
28 Correct 178 ms 16804 KB Output is correct
29 Correct 224 ms 21572 KB Output is correct
30 Correct 97 ms 13604 KB Output is correct
31 Correct 250 ms 23212 KB Output is correct
32 Correct 117 ms 18032 KB Output is correct
33 Incorrect 123 ms 19780 KB Output isn't correct
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -