답안 #1106844

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1106844 2024-10-31T07:54:12 Z VectorLi Restore Array (RMI19_restore) C++17
컴파일 오류
0 ms 0 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;
}

Compilation message

restore.cpp: In function 'void solve()':
restore.cpp:54:52: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   54 |  if (find(d, d + n + 1, numeric_limits<int>::max() != d + n + 1) {
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
restore.cpp:54:65: error: expected ')' before '{' token
   54 |  if (find(d, d + n + 1, numeric_limits<int>::max() != d + n + 1) {
      |     ~                                                           ^~
      |                                                                 )
restore.cpp:54:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   54 |  if (find(d, d + n + 1, numeric_limits<int>::max() != d + n + 1) {
      |  ^~
restore.cpp:58:18: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   58 |  for (int i = 1; i <= n; i++) {
      |                  ^
restore.cpp:58:18: error: 'i' was not declared in this scope