/**
* author: wxhtzdy
* created: 18.12.2022 21:11:23
**/
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<tuple<int, int, int>> q;
for (int i = 0; i < m; i++) {
int l, r, k, v;
cin >> l >> r >> k >> v;
int len = r - l + 1;
if (v == 0) {
q.emplace_back(l, r, len - k);
}
if (v == 1) {
q.emplace_back(r, l, -(len - k + 1));
}
}
for (int i = 0; i < n - 1; i++) {
q.emplace_back(i, i + 1, 1);
q.emplace_back(i + 1, i, 0);
}
const long long inf = (long long) 1e18;
vector<long long> d(n, inf);
d[0] = 0;
for (int iter = 0; iter < n + 1; iter++) {
bool any = false;
for (auto& p : q) {
int i = get<0>(p);
int j = get<1>(p);
int w = get<2>(p);
if (d[i] < inf && d[j] > d[i] + w) {
d[j] = max(-inf, d[i] + w);
any = true;
}
}
if (iter == n && any) {
cout << -1 << '\n';
return 0;
}
}
int prv = 0;
for (int i = 0; i < n; i++) {
cout << d[i] - prv << " ";
prv = d[i];
}
cout << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
142 ms |
916 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
142 ms |
916 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |