#include <bits/stdc++.h>
using namespace std;
const int MXN = 5e3 + 5;
int n, m;
vector<array<int, 3>> ed;
int dist[MXN];
int add(int a, int b)
{
return a + b;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 0; i < n; i++)
{
ed.push_back({i, add(i, 1), 1});
ed.push_back({add(i, 1), i, 0});
}
for (int i = 1; i <= n; i++) dist[i] = add(n, 10);
while (m--)
{
int l, r, k, v;
cin >> l >> r >> k >> v;
r++;
int sz = r - l;
if (v == 1)
{
int mx = sz;
int mn = sz - k + 1;
//~ ed.push_back({r, l, (int)(-mn)});
}
else
{
int mn = 0;
int mx = sz - k;
ed.push_back({l, r, mx});
}
}
bool f = 0;
for (int i = 1; i <= n + 1; i++)
{
f = 0;
for (const array<int, 3> &x : ed)
{
if (add(dist[x[0]], x[2]) < dist[x[1]])
{
f = 1;
dist[x[1]] = add(dist[x[0]], x[2]);
}
}
}
if (f)
{
cout << -1 << '\n';
return 0;
}
for (int i = 1; i <= n; i++)
{
cout << dist[i] - dist[i - 1] << ' ';
}
cout << '\n';
}
Compilation message
restore.cpp: In function 'int main()':
restore.cpp:34:17: warning: unused variable 'mx' [-Wunused-variable]
34 | int mx = sz;
| ^~
restore.cpp:35:17: warning: unused variable 'mn' [-Wunused-variable]
35 | int mn = sz - k + 1;
| ^~
restore.cpp:40:17: warning: unused variable 'mn' [-Wunused-variable]
40 | int mn = 0;
| ^~
# |
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 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
820 KB |
Output is correct |
2 |
Correct |
78 ms |
816 KB |
Output is correct |
3 |
Correct |
78 ms |
796 KB |
Output is correct |
4 |
Incorrect |
79 ms |
820 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
820 KB |
Output is correct |
2 |
Correct |
78 ms |
816 KB |
Output is correct |
3 |
Correct |
78 ms |
796 KB |
Output is correct |
4 |
Incorrect |
79 ms |
820 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |