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>
// author : a1abay
using namespace std;
int n, m, l, r, k, v;
vector<array<int, 3>> e;
vector<int> d(5001, 5001);
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for(int i = 0; i < n; i++)
{
e.push_back({i, i + 1, 1});
e.push_back({i + 1, i, 0});
}
while(m--)
{
cin >> l >> r >> k >> v;
if(!v) e.push_back({l, r + 1, r - l + 1 - k});
else e.push_back({r + 1, l, -(r - l + 1 - k + 1)});
}
d[0] = 0;
for(int i = 1; i <= n; i++)
{
for(auto p : e)
{
if(d[p[0]] + p[2] < d[p[1]])
{
d[p[1]] = d[p[0]] + p[2];
if(i == n)
{
cout << -1;
return 0;
}
}
}
}
for(int i = 1; i <= n; i++) cout << d[i] - d[i - 1] << ' ';
}
# | 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... |