Submission #431370

# Submission time Handle Problem Language Result Execution time Memory
431370 2021-06-17T11:24:30 Z _fractal Sky Walking (IOI19_walk) C++14
24 / 100
2987 ms 472768 KB
#include "walk.h"
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iostream>
using namespace std;
 
vector<pair<int, int>> g[1 << 21];
vector<long long> dp(1 << 21, -1);
 
long long min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int s, int e) {
	int n = x.size();
	int m = l.size();
	int sz = n - 1;
	vector<pair<int, int>> add, now;
	set<int> is;
	map<int, int> can[n];
	for (int i = 0; i < m; ++i)
		add.push_back({y[i], i});
	for (int i = 0; i < n; ++i)
		now.push_back({h[i], i});
	sort(add.begin(), add.end());
	reverse(add.begin(), add.end());
	sort(now.begin(), now.end());
	for (int i = 0; i < m; ++i) {
		int j = add[i].second;
		while (now.size() && now.back().first >= add[i].first) {
			is.insert(now.back().second);
			now.pop_back();
		}
		auto it = is.lower_bound(l[j]);
		while (it != is.end() && *it <= r[j]) {
			if (it == is.end()) break;
			if (!can[*it].count(y[j]))
				can[*it][y[j]] = ++sz;
			if (it != is.begin() && *prev(it) >= l[j]) {
				g[can[*it][y[j]]].push_back({can[*prev(it)][y[j]], x[*it] - x[*prev(it)]});
				g[can[*prev(it)][y[j]]].push_back({can[*it][y[j]], x[*it] - x[*prev(it)]});
			}
			it = next(it);
		}
	}
	for (int i = 0; i < n; ++i) {
		int last = 0, pos = i;
 
		for (auto it = can[i].begin(); it != can[i].end(); ++it) {
			g[pos].push_back({it->second, it->first - last});
			g[it->second].push_back({pos, it->first - last});
			last = it->first;
			pos = it->second;
		}
	}
	priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;
	q.push({0, s});
	dp[s] = 0;
	while (!q.empty()) {
		int v = q.top().second;
		long long C = q.top().first;
		q.pop();
		if (dp[v] < C)
			continue;
		for (auto [to, c] : g[v]) {
			if (dp[to] == -1 || dp[to] > dp[v] + c) {
				dp[to] = dp[v] + c;
				q.push({dp[to], to});	
			}
		}
	}
	return dp[e];
}

Compilation message

walk.cpp: In function 'long long int min_distance(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, int, int)':
walk.cpp:64:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   64 |   for (auto [to, c] : g[v]) {
      |             ^
# Verdict Execution time Memory Grader output
1 Correct 47 ms 65852 KB Output is correct
2 Correct 49 ms 65860 KB Output is correct
3 Correct 45 ms 65944 KB Output is correct
4 Correct 48 ms 65948 KB Output is correct
5 Correct 49 ms 66032 KB Output is correct
6 Correct 47 ms 65976 KB Output is correct
7 Correct 48 ms 65940 KB Output is correct
8 Correct 43 ms 65976 KB Output is correct
9 Correct 45 ms 65976 KB Output is correct
10 Correct 48 ms 66060 KB Output is correct
11 Correct 43 ms 65952 KB Output is correct
12 Correct 45 ms 65976 KB Output is correct
13 Correct 47 ms 65920 KB Output is correct
14 Correct 47 ms 65948 KB Output is correct
15 Correct 47 ms 65952 KB Output is correct
16 Correct 47 ms 65932 KB Output is correct
17 Correct 49 ms 66060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 65960 KB Output is correct
2 Correct 43 ms 65860 KB Output is correct
3 Correct 1564 ms 155504 KB Output is correct
4 Correct 1426 ms 168780 KB Output is correct
5 Correct 939 ms 156176 KB Output is correct
6 Correct 764 ms 146180 KB Output is correct
7 Correct 868 ms 156072 KB Output is correct
8 Correct 2025 ms 180532 KB Output is correct
9 Correct 1056 ms 153392 KB Output is correct
10 Correct 1918 ms 206512 KB Output is correct
11 Correct 785 ms 116124 KB Output is correct
12 Correct 574 ms 105200 KB Output is correct
13 Correct 1595 ms 190140 KB Output is correct
14 Correct 373 ms 103568 KB Output is correct
15 Correct 437 ms 104472 KB Output is correct
16 Correct 425 ms 105096 KB Output is correct
17 Correct 472 ms 103072 KB Output is correct
18 Correct 345 ms 101116 KB Output is correct
19 Correct 53 ms 67780 KB Output is correct
20 Correct 159 ms 84824 KB Output is correct
21 Correct 401 ms 102092 KB Output is correct
22 Correct 460 ms 104348 KB Output is correct
23 Correct 459 ms 112492 KB Output is correct
24 Correct 433 ms 104340 KB Output is correct
25 Correct 436 ms 102832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 166 ms 75436 KB Output is correct
2 Runtime error 2987 ms 472768 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 166 ms 75436 KB Output is correct
2 Runtime error 2987 ms 472768 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 65852 KB Output is correct
2 Correct 49 ms 65860 KB Output is correct
3 Correct 45 ms 65944 KB Output is correct
4 Correct 48 ms 65948 KB Output is correct
5 Correct 49 ms 66032 KB Output is correct
6 Correct 47 ms 65976 KB Output is correct
7 Correct 48 ms 65940 KB Output is correct
8 Correct 43 ms 65976 KB Output is correct
9 Correct 45 ms 65976 KB Output is correct
10 Correct 48 ms 66060 KB Output is correct
11 Correct 43 ms 65952 KB Output is correct
12 Correct 45 ms 65976 KB Output is correct
13 Correct 47 ms 65920 KB Output is correct
14 Correct 47 ms 65948 KB Output is correct
15 Correct 47 ms 65952 KB Output is correct
16 Correct 47 ms 65932 KB Output is correct
17 Correct 49 ms 66060 KB Output is correct
18 Correct 49 ms 65960 KB Output is correct
19 Correct 43 ms 65860 KB Output is correct
20 Correct 1564 ms 155504 KB Output is correct
21 Correct 1426 ms 168780 KB Output is correct
22 Correct 939 ms 156176 KB Output is correct
23 Correct 764 ms 146180 KB Output is correct
24 Correct 868 ms 156072 KB Output is correct
25 Correct 2025 ms 180532 KB Output is correct
26 Correct 1056 ms 153392 KB Output is correct
27 Correct 1918 ms 206512 KB Output is correct
28 Correct 785 ms 116124 KB Output is correct
29 Correct 574 ms 105200 KB Output is correct
30 Correct 1595 ms 190140 KB Output is correct
31 Correct 373 ms 103568 KB Output is correct
32 Correct 437 ms 104472 KB Output is correct
33 Correct 425 ms 105096 KB Output is correct
34 Correct 472 ms 103072 KB Output is correct
35 Correct 345 ms 101116 KB Output is correct
36 Correct 53 ms 67780 KB Output is correct
37 Correct 159 ms 84824 KB Output is correct
38 Correct 401 ms 102092 KB Output is correct
39 Correct 460 ms 104348 KB Output is correct
40 Correct 459 ms 112492 KB Output is correct
41 Correct 433 ms 104340 KB Output is correct
42 Correct 436 ms 102832 KB Output is correct
43 Correct 166 ms 75436 KB Output is correct
44 Runtime error 2987 ms 472768 KB Execution killed with signal 11
45 Halted 0 ms 0 KB -