Submission #954281

# Submission time Handle Problem Language Result Execution time Memory
954281 2024-03-27T15:07:38 Z colossal_pepe Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
299 ms 2568 KB
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
using namespace std;

int n, m;
vector<int> b, p;
vector<vector<int>> v;

int solve() {
	vector<int> dist(m, -1);
	priority_queue<tuple<int, int, int>> q;
	dist[b[0]] = 0;
	q.push({0, b[0], 0});
	while (not q.empty() and dist[1] == -1) {
		auto [d, i, j] = q.top();
		q.pop();
		while (not v[i].empty()) {
			dist[v[i].back()] = -d;
			q.push(make_tuple(d, i, v[i].back()));
			v[i].pop_back();
		}
		if (i >= b[j] and i + p[j] < n) q.push(make_tuple(d - 1, i + p[j], j));
		if (i <= b[j] and i - p[j] >= 0) q.push(make_tuple(d - 1, i - p[j], j));
	}
	return dist[1];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;
	v.resize(n), b.resize(m), p.resize(m);
	cin >> b[0] >> p[0];
	for (int i = 1; i < m; i++) {
		cin >> b[i] >> p[i];
		v[b[i]].push_back(i);
	}
	cout << solve() << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 352 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 352 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 352 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 291 ms 916 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 5 ms 544 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 12 ms 604 KB Output is correct
34 Correct 7 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 516 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 283 ms 672 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 856 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 5 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 2 ms 532 KB Output is correct
33 Correct 12 ms 600 KB Output is correct
34 Correct 7 ms 600 KB Output is correct
35 Correct 8 ms 1372 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 4 ms 1216 KB Output is correct
38 Correct 10 ms 1820 KB Output is correct
39 Correct 5 ms 1372 KB Output is correct
40 Correct 5 ms 1400 KB Output is correct
41 Correct 9 ms 1820 KB Output is correct
42 Correct 3 ms 1116 KB Output is correct
43 Correct 4 ms 1624 KB Output is correct
44 Correct 293 ms 2040 KB Output is correct
45 Correct 61 ms 1628 KB Output is correct
46 Correct 36 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 0 ms 528 KB Output is correct
20 Correct 289 ms 1140 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 600 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 5 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 11 ms 604 KB Output is correct
34 Correct 7 ms 604 KB Output is correct
35 Correct 8 ms 1372 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 4 ms 1204 KB Output is correct
38 Correct 10 ms 1816 KB Output is correct
39 Correct 5 ms 1372 KB Output is correct
40 Correct 6 ms 1368 KB Output is correct
41 Correct 9 ms 1820 KB Output is correct
42 Correct 4 ms 1328 KB Output is correct
43 Correct 4 ms 1620 KB Output is correct
44 Correct 299 ms 2124 KB Output is correct
45 Correct 60 ms 1624 KB Output is correct
46 Correct 35 ms 1628 KB Output is correct
47 Correct 7 ms 1628 KB Output is correct
48 Correct 5 ms 1884 KB Output is correct
49 Correct 5 ms 1884 KB Output is correct
50 Correct 3 ms 1628 KB Output is correct
51 Correct 11 ms 2396 KB Output is correct
52 Correct 16 ms 2568 KB Output is correct
53 Correct 6 ms 2396 KB Output is correct
54 Correct 1 ms 1116 KB Output is correct
55 Runtime error 1 ms 1988 KB Execution killed with signal 11
56 Halted 0 ms 0 KB -