#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e4 + 5;
int N, M, l[MAX], r[MAX], k[MAX], v[MAX];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
freopen("task.inp", "r", stdin);
freopen("task.out", "w", stdout);
#endif // LOCAL
cin >> N >> M;
for(int i = 0; i < M; ++i){
cin >> l[i] >> r[i] >> k[i] >> v[i];
}
if(N <= 18){
for(int mask = 0; mask < (1 << N); ++mask){
bool sat = true;
for(int i = 0; i < M; ++i){
int S = (1 << r[i]) - 1;
if(l[i] > 0) S ^= (1 << (l[i] - 1)) - 1;
int cur = (r[i] - l[i] + 1) - (__builtin_popcount(S & mask));
if(v[i] == 1 && cur < k[i]);
else if(v[i] == 0 && cur >= k[i]);
else{
sat = false;
break;
}
}
if(sat){
for(int i = 0; i < N; ++i){
cout << (mask >> i & 1) << ' ';
}
return 0;
}
}
cout << -1 << '\n';
return 0;
}
return 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... |