This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
restore.cpp: In function 'int main()':
restore.cpp:34:17: warning: unused variable 'mx' [-Wunused-variable]
34 | int mx = sz;
| ^~
restore.cpp:40:17: warning: unused variable 'mn' [-Wunused-variable]
40 | int mn = 0;
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |