#include <bits/stdc++.h>
using namespace std;
const int NMAX = 5e3;
const int MMAX = 1e4;
int ans[NMAX];
struct op {
int l, r, minimum, nr;
bool active;
} v[MMAX];
int main() {
int n, m;
cin >> n >> m;
for(int i = 0; i < m; i++) {
int l, r, k, nr;
cin >> l >> r >> k >> nr;
if(nr == 0) {
v[i] = {l, r, k, 0, true};
} else {
v[i] = {l, r, r - l + 1 - k + 1, 1, true};
}
}
bool isPossible = true;
for(int i = 0; i < n; i++) {
int max0 = 0, max1 = 0;
for(int j = 0; j < m; j++) {
if(v[j].active) {
if(v[j].l == i) {
if(v[j].nr == 0)
max0 = max(max0, v[j].minimum);
else max1 = max(max1, v[j].minimum);
}
}
}
if(max0 > max1) {
ans[i] = 0;
} else ans[i] = 1;
for(int j = 0; j < m; j++) {
if(v[j].active) {
if(v[j].l == i) {
if(v[j].nr == ans[i])
v[j].minimum--;
v[j].l++;
if(v[j].l > v[j].r) {
if(v[j].minimum > 0)
isPossible = false;
else
v[j].active = false;
}
}
}
}
}
if(isPossible) {
for(int i = 0; i < n; i++)
cout << ans[i] << ' ';
} else cout << -1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
307 ms |
864 KB |
Output is correct |
2 |
Correct |
316 ms |
608 KB |
Output is correct |
3 |
Correct |
305 ms |
604 KB |
Output is correct |
4 |
Correct |
326 ms |
620 KB |
Output is correct |
5 |
Correct |
398 ms |
608 KB |
Output is correct |
6 |
Correct |
359 ms |
616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
307 ms |
864 KB |
Output is correct |
2 |
Correct |
316 ms |
608 KB |
Output is correct |
3 |
Correct |
305 ms |
604 KB |
Output is correct |
4 |
Correct |
326 ms |
620 KB |
Output is correct |
5 |
Correct |
398 ms |
608 KB |
Output is correct |
6 |
Correct |
359 ms |
616 KB |
Output is correct |
7 |
Incorrect |
434 ms |
620 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |