#include <bits/stdc++.h>
#define ll long long
#define rep(i,m,n) for(int i=(m); i<=(n); i++)
#define reb(i,m,n) for(int i=(m); i>=(n); i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair
#define fs first
#define se second
#define bit(msk, i) ((msk >> i) & 1)
#define iter(id, v) for(auto id : v)
#define pb push_back
#define SZ(v) (int)v.size()
#define ALL(v) v.begin(),v.end()
using namespace std;
mt19937_64 rd(chrono :: steady_clock :: now ().time_since_epoch().count());
ll Rand (ll l, ll r) { return uniform_int_distribution<ll> (l, r) (rd); }
const int N = 20 + 7;
const int Mod = 1e9 + 7;
const int INF = 1e9 + 7;
const ll BASE = 137;
const int szBL = 320;
struct Query {
int l, r, k, val;
};
int n, Q;
int a[N];
Query qr[N];
void solution () {
cin >> n >> Q;
rep (i, 1, Q) {
cin >>qr[i].l >> qr[i].r >> qr[i].k >> qr[i].val;
++qr[i].l;
++qr[i].r;
}
rep (i, 1, n) a[i] = 3;
sort (qr + 1, qr + 1 + Q, [] (Query A, Query B) { return A.r < B.r || (A.r == B.r && A.l > B.l); });
// cout<<"\n";
rep (q, 1, Q) {
Query &cur = qr[q];
// cout << cur.l <<" "<<cur.r<<" "<<cur.k <<" "<<cur.val<<"\n";
int wanted = cur.val, num;
if (wanted == 1) num = cur.r - cur.l + 1 - cur.k + 1;
else num = cur.k;
rep (i, cur.l, cur.r) {
if (num == 0) break;
if (a[i] == 3) a[i] = wanted, --num;
else {
if (a[i] == wanted) --num;
}
}
if (num > 0) {
cout << -1 <<"\n";
return;
}
}
rep (i, 1, n) if (a[i] == 3) a[i] = 0;
rep (i, 1, n) {
cout << a[i] <<" ";
}
}
#define file(name) freopen(name".inp","r",stdin); \
freopen(name".out","w",stdout);
int main () {
// file("c");
ios_base :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
int num_Test = 1;
// cin >> num_Test;
while (num_Test--)
solution();
}
/*
no bug challenge +2
2 + 8 * 2 - 9
6 2
1 5 2 3 1 1
1 2 3 3 2
4 5
6 6
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 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 |
- |