Submission #1106845

# Submission time Handle Problem Language Result Execution time Memory
1106845 2024-10-31T07:54:37 Z VectorLi Restore Array (RMI19_restore) C++17
0 / 100
5 ms 5968 KB
#include <bits/stdc++.h>
#define long long long

using namespace std;

const int N = (int) 2E5;

int n, m;
vector<pair<int, int>> e[N + 1];

int d[N + 1];
priority_queue<pair<int, int>> q;

void Dijkstra(int x) {
	fill(d, d + n + 1, numeric_limits<int>::max());
	d[x] = 0;
	q.push({0 - d[x], x});
	
	while (q.empty() == 0) {
		auto [t, u] = q.top();
		q.pop();
		t = 0 - t;
		if (t != d[u]) {
			continue;
		}
		for (auto [v, w] : e[u]) {
			if (d[v] > d[u] + w) {
				d[v] = d[u] + w;
				q.push({0 - d[v], v});
			}
		}
	}
}

void solve() {
	cin >> n >> m;
	for (int i = 0; i <= n - 1; i++) {
		e[i + 1].push_back({i, 0});
		e[i].push_back({i + 1, 1});
	}
	for (int i = 0; i < m; i++) {
		int l, r;
		int k, x;
		cin >> l >> r >> k >> x;
		l = l + 1;
		r = r + 1;
		if (x == 0) {
			e[r].push_back({l - 1, k});
		} else {
			e[l - 1].push_back({r, (k - 1)});
		}
	}
	Dijkstra(0);
	if (find(d, d + n + 1, numeric_limits<int>::max()) != (d + n + 1)) {
		cout << 0 - 1 << "\n";
		exit(0);
	}
	for (int i = 1; i <= n; i++) {
		if (d[i] - d[i - 1] == 0) {
			cout << 1 << " ";
		} else {
			cout << 0 << " ";
		}
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	int t;
	t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5712 KB Output is correct
2 Incorrect 2 ms 5712 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5968 KB Output is correct
2 Correct 4 ms 5968 KB Output is correct
3 Correct 4 ms 5968 KB Output is correct
4 Correct 5 ms 5968 KB Output is correct
5 Incorrect 5 ms 5968 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5968 KB Output is correct
2 Correct 4 ms 5968 KB Output is correct
3 Correct 4 ms 5968 KB Output is correct
4 Correct 5 ms 5968 KB Output is correct
5 Incorrect 5 ms 5968 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5712 KB Output is correct
2 Incorrect 2 ms 5712 KB Output isn't correct
3 Halted 0 ms 0 KB -