Submission #954854

# Submission time Handle Problem Language Result Execution time Memory
954854 2024-03-28T18:00:49 Z colossal_pepe Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 2956 KB
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
 
int n, m;
vector<int> b, p;
vector<vector<int>> v;
 
int solve() {
	vector<int> dist(m, -1);
	queue<pair<int, int>> q[2];
	dist[0] = 0;
	q[0].push({b[0], 0});
	while ((q[0].size() or q[1].size()) and dist[1] == -1) {
		int o = q[0].empty();
		auto [i, j] = q[o].front();
		q[o].pop();
		while (not v[i].empty()) {
			dist[v[i].back()] = dist[j] + (abs(i - b[j]) / p[j]);
			q[0].push({i, v[i].back()});
			v[i].pop_back();
		}
		if (i >= b[j] and i + p[j] < n) q[1].push({i + p[j], j});
		if (i <= b[j] and i - p[j] >= 0) q[1].push({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 1 ms 352 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
# 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 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 396 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
# 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 456 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 448 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 700 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 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 352 KB Output is correct
20 Correct 38 ms 604 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 2 ms 348 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 1 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 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 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 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 348 KB Output is correct
20 Correct 39 ms 596 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 600 KB Output is correct
23 Correct 1 ms 464 KB Output is correct
24 Correct 1 ms 504 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 348 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 452 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 472 KB Output is correct
34 Correct 2 ms 344 KB Output is correct
35 Correct 5 ms 1116 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 4 ms 1368 KB Output is correct
38 Correct 5 ms 1368 KB Output is correct
39 Correct 5 ms 1372 KB Output is correct
40 Correct 5 ms 1372 KB Output is correct
41 Correct 5 ms 1372 KB Output is correct
42 Correct 4 ms 1268 KB Output is correct
43 Correct 4 ms 1372 KB Output is correct
44 Correct 44 ms 1504 KB Output is correct
45 Correct 11 ms 1372 KB Output is correct
46 Correct 7 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 460 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 436 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 464 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 348 KB Output is correct
20 Correct 39 ms 616 KB Output is correct
21 Correct 1 ms 348 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 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 456 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 6 ms 1116 KB Output is correct
36 Correct 1 ms 588 KB Output is correct
37 Correct 3 ms 1116 KB Output is correct
38 Correct 5 ms 1372 KB Output is correct
39 Correct 4 ms 1372 KB Output is correct
40 Correct 5 ms 1368 KB Output is correct
41 Correct 5 ms 1372 KB Output is correct
42 Correct 3 ms 984 KB Output is correct
43 Correct 4 ms 1880 KB Output is correct
44 Correct 45 ms 1488 KB Output is correct
45 Correct 11 ms 1372 KB Output is correct
46 Correct 8 ms 1372 KB Output is correct
47 Correct 5 ms 1680 KB Output is correct
48 Correct 5 ms 1884 KB Output is correct
49 Correct 5 ms 1884 KB Output is correct
50 Correct 4 ms 1624 KB Output is correct
51 Correct 8 ms 2396 KB Output is correct
52 Correct 8 ms 2396 KB Output is correct
53 Correct 7 ms 2396 KB Output is correct
54 Correct 1 ms 960 KB Output is correct
55 Correct 1 ms 1116 KB Output is correct
56 Execution timed out 1089 ms 2956 KB Time limit exceeded
57 Halted 0 ms 0 KB -