#include <bits/stdc++.h>
using namespace std;
const int N = 20300;
int f[N], t[N], w[N];
int sz;
int d[N];
int main()
{
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++)
{
int l, r, k, v;
cin >> l >> r >> k >> v;
r++;
if (v == 0)
{
// k-th = zero, at most len-k ones
f[sz] = l;
t[sz] = r;
w[sz] = r - l - k;
sz++;
}
else
{
// k-th = one, at least len - k ones
f[sz] = r;
t[sz] = l;
w[sz] = -(r - l - k);
sz++;
}
}
for (int i = 0; i < n; i++)
{
f[sz] = i;
t[sz] = i + 1;
w[sz] = 1;
sz++;
}
for (int i = 1; i <= n; i++)
{
d[i] = 1e9;
f[sz] = i;
t[sz] = i - 1;
w[sz] = 0;
sz++;
}
for (int i = 0; i <= n; i++)
{
for (int j = 0; j < sz; j++)
{
if (d[f[j]] + w[j] < d[t[j]])
{
d[t[j]] = d[f[j]] + w[j];
}
}
}
for (int j = 0; j < sz; j++)
{
if (d[f[j]] + w[j] < d[t[j]])
{
cout << -1;
return 0;
}
}
for (int i = 1; i <= n; i++)
{
cout << d[i] - d[i - 1] << " ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
161 ms |
748 KB |
Output is correct |
2 |
Correct |
165 ms |
764 KB |
Output is correct |
3 |
Correct |
179 ms |
748 KB |
Output is correct |
4 |
Incorrect |
164 ms |
764 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
161 ms |
748 KB |
Output is correct |
2 |
Correct |
165 ms |
764 KB |
Output is correct |
3 |
Correct |
179 ms |
748 KB |
Output is correct |
4 |
Incorrect |
164 ms |
764 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |