#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define sz(a) (int)a.size()
bool check(vector<int>& a, vector<array<int,4>>& q)
{
int n = sz(a), m = sz(q);
vector<int> p(n);
forn(i, n){
p[i] = a[i];
if(i)p[i] += p[i - 1];
}
bool ok = true;
for(int i = 0;i < m;++i){
int l = q[i][0], r = q[i][1], k = q[i][2], val = q[i][3];
int zeroes = (r - l + 1) - p[r];
if(l)zeroes += p[l - 1];
int number = 0;
if(zeroes >= k)number = 0;
else number = 1;
if(number != val)ok = false;
}
return ok;
}
void solve()
{
int n, m;
cin >> n >> m;
vector<array<int, 4>> q(m);
for(int i = 0;i < m;++i){
int l, r, k, val;
cin >> l >> r >> k >> val;
q[i] = {l, r, k, val};
}
if(n <= 18)
{
for(int mask = 0;mask < (1 << n);++mask){
vector<int> a(n, 0);
vector<int> p(n, 0);
for(int i = 0;i < n;++i){
if(mask & (1 << i))a[i] = 1;
p[i] = a[i];
if(i)p[i] += p[i - 1];
}
if(check(a, q)){
forn(i, n)cout << a[i] << " ";
cout << "\n";
return;
}
}
cout << "-1\n";
return;
}
}
int32_t main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
//cin >> t;
while(t--)
{
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
34 ms |
204 KB |
Output is correct |
4 |
Correct |
32 ms |
204 KB |
Output is correct |
5 |
Correct |
137 ms |
288 KB |
Output is correct |
6 |
Correct |
63 ms |
204 KB |
Output is correct |
7 |
Correct |
26 ms |
204 KB |
Output is correct |
8 |
Correct |
26 ms |
204 KB |
Output is correct |
9 |
Correct |
140 ms |
288 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
460 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
460 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
34 ms |
204 KB |
Output is correct |
4 |
Correct |
32 ms |
204 KB |
Output is correct |
5 |
Correct |
137 ms |
288 KB |
Output is correct |
6 |
Correct |
63 ms |
204 KB |
Output is correct |
7 |
Correct |
26 ms |
204 KB |
Output is correct |
8 |
Correct |
26 ms |
204 KB |
Output is correct |
9 |
Correct |
140 ms |
288 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Incorrect |
3 ms |
460 KB |
Unexpected end of file - int32 expected |
12 |
Halted |
0 ms |
0 KB |
- |