#include <bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
using namespace std;
#define vint vector<int>
#define all(v) v.begin(), v.end()
#define MOD 1000000007
#define MOD2 998244353
#define MX 1000000000
#define MXL 1000000000000000000
#define PI (ld)2*acos(0.0)
#define nax 200005
#define pb push_back
#define sc second
#define fr first
#define int long long
#define endl '\n'
#define ld long double
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
int ceildiv(int one, int two) {if (one % two == 0) {return one / two;}else {return one / two + 1;}} int power(int n, int pow, int m) {if (pow == 0) return 1;if (pow % 2 == 0) {ll x = power(n, pow / 2, m);return (x * x) % m;}else return (power(n, pow - 1, m) * n) % m;} int gcd(int a, int b) { if (!b)return a; return gcd(b, a % b);} int factorial(int n, int mod) {if (n > 1)return (n * factorial(n - 1, mod)) % mod; else return 1;} int lcm(int a, int b) {return (a * b) / gcd(a, b);} vector<int> read(int n) {vector<int> a; for (int i = 0; i < n; i++) { int x; cin >> x; a.pb(x);} return a;}//ssense
vector<pair<pair<int, int>, pair<int, int>>> ranges;
int n, m;
bool calc(int num)
{
vint now;
for(int j = 0; j < n; j++)
{
now.pb(num%2);
num/=2;
}
vint pref;
pref.pb(0);
for(int i = 0; i < n; i++)
{
pref.pb(pref.back()+now[i]);
}
for(int i = 0; i < ranges.size(); i++)
{
int sum = pref[ranges[i].fr.sc+1]-pref[ranges[i].fr.fr];
int tot = ranges[i].fr.sc+1-ranges[i].fr.fr;
if(tot-sum < ranges[i].sc.fr && ranges[i].sc.sc == 0)
{
return false;
}
if(tot-sum > ranges[i].sc.fr && ranges[i].sc.sc == 1)
{
return false;
}
}
return true;
}
void solve()
{
cin >> n >> m;
for(int i = 0; i < m; i++)
{
pair<pair<int, int>, pair<int, int>> nw;
cin >> nw.fr.fr >> nw.fr.sc >> nw.sc.fr >> nw.sc.sc;
ranges.pb(nw);
}
for(int i = 0; i < 1<<n; i++)
{
if(calc(i))
{
vint now;
for(int j = 0; j < n; j++)
{
now.pb(i%2);
i/=2;
}
for(auto x: now)
{
cout << x << " ";
}
}
}
}
int32_t main(){
startt;
int t = 1;
//cin >> t;
while (t--)
{
solve();
}
}
Compilation message
restore.cpp: In function 'bool calc(long long int)':
restore.cpp:39:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::pair<long long int, long long int>, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int i = 0; i < ranges.size(); i++)
| ~~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1047 ms |
1596 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
976 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
976 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1047 ms |
1596 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |