/**
* user: vukelic-2d0
* fname: Mateja
* lname: Vukelic
* task: restore
* score: 20.0
* date: 2019-10-10 06:43:39.802357
*/
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
struct upit{
int l,r,k,val;
};
vector<upit>v;
int n,m;
int poj1 = 0;
int pojk = 0;
int suff[5005];
void check(int x){
for(int i=0; i<=n; i++)suff[i] = 0;
vector<int>cif;
for(int i=0; i<n; i++){
if((1<<i)&x){
cif.pb(1);
suff[n-i-1]++;
}
else cif.pb(0);
suff[n-i-1] += suff[n - i];
}
reverse(cif.begin(), cif.end());
for(auto c:v){
int koja;
int kolko = suff[c.l] - suff[c.r + 1];
int br0 = c.r - c.l + 1 - kolko;
if(c.k <= br0)koja = 0;
else koja = 1;
if(koja != c.val){
return;
}
}
for(auto p:cif)cout << p << " ";
exit(0);
}
int niz[5005];
void check2(){
for(int i=n-1; i>=0; i--){
if(niz[i] == 1)suff[i]++;
suff[i] += suff[i + 1];
}
for(auto c:v){
int koja;
int kolko = suff[c.l] - suff[c.r + 1];
int br0 = c.r - c.l + 1 - kolko;
if(c.k <= br0)koja = 0;
else koja = 1;
if(koja != c.val){
return;
}
}
for(int i=0; i<n; i++)cout << niz[i] << " ";
exit(0);
}
bool use[5005];
int main()
{
ios_base::sync_with_stdio(false);
cin >> n >> m;
for(int i=0; i<m; i++){
int a,b,c,d;
cin >> a >> b >> c >> d;
v.pb({a,b,c,d});
if(c == 1)poj1++;
else if(c == b-a + 1)pojk++;
}
if(n <= 18){
for(int i=0; i<(1<<n); i++){
check(i);
}
cout << -1 << endl;
return 0;
}
if(poj1 == m){
for(auto c:v){
if(c.val == 1){
for(int i=c.l; i<=c.r; i++)niz[i] = 1;
}
}
check2();
cout << -1;
return 0;
}
if(poj1 + pojk == m){
}
return 0;
}
/*
4 5
0 1 2 1
0 2 2 0
2 2 1 0
0 1 1 0
1 2 1 0
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
10 ms |
376 KB |
Output is correct |
4 |
Correct |
68 ms |
376 KB |
Output is correct |
5 |
Correct |
128 ms |
376 KB |
Output is correct |
6 |
Correct |
66 ms |
376 KB |
Output is correct |
7 |
Correct |
12 ms |
376 KB |
Output is correct |
8 |
Correct |
18 ms |
376 KB |
Output is correct |
9 |
Correct |
74 ms |
376 KB |
Output is correct |
10 |
Correct |
44 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
760 KB |
Output is correct |
2 |
Correct |
6 ms |
760 KB |
Output is correct |
3 |
Correct |
6 ms |
760 KB |
Output is correct |
4 |
Correct |
6 ms |
760 KB |
Output is correct |
5 |
Correct |
7 ms |
764 KB |
Output is correct |
6 |
Correct |
8 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
760 KB |
Output is correct |
2 |
Correct |
6 ms |
760 KB |
Output is correct |
3 |
Correct |
6 ms |
760 KB |
Output is correct |
4 |
Correct |
6 ms |
760 KB |
Output is correct |
5 |
Correct |
7 ms |
764 KB |
Output is correct |
6 |
Correct |
8 ms |
760 KB |
Output is correct |
7 |
Incorrect |
6 ms |
760 KB |
Unexpected end of file - int32 expected |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
10 ms |
376 KB |
Output is correct |
4 |
Correct |
68 ms |
376 KB |
Output is correct |
5 |
Correct |
128 ms |
376 KB |
Output is correct |
6 |
Correct |
66 ms |
376 KB |
Output is correct |
7 |
Correct |
12 ms |
376 KB |
Output is correct |
8 |
Correct |
18 ms |
376 KB |
Output is correct |
9 |
Correct |
74 ms |
376 KB |
Output is correct |
10 |
Correct |
44 ms |
376 KB |
Output is correct |
11 |
Correct |
6 ms |
760 KB |
Output is correct |
12 |
Correct |
6 ms |
760 KB |
Output is correct |
13 |
Correct |
6 ms |
760 KB |
Output is correct |
14 |
Correct |
6 ms |
760 KB |
Output is correct |
15 |
Correct |
7 ms |
764 KB |
Output is correct |
16 |
Correct |
8 ms |
760 KB |
Output is correct |
17 |
Incorrect |
6 ms |
760 KB |
Unexpected end of file - int32 expected |
18 |
Halted |
0 ms |
0 KB |
- |