Submission #954262

# Submission time Handle Problem Language Result Execution time Memory
954262 2024-03-27T14:48:16 Z colossal_pepe Jakarta Skyscrapers (APIO15_skyscraper) C++17
10 / 100
1 ms 600 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[b[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 + p[j] < n) q[1].push({i + p[j], j});
		if (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 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 0 ms 348 KB Output is correct
7 Correct 0 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 456 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 0 ms 448 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 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 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 428 KB Output is correct
5 Correct 1 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 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -