Submission #481549

# Submission time Handle Problem Language Result Execution time Memory
481549 2021-10-21T06:42:04 Z ssense Restore Array (RMI19_restore) C++14
0 / 100
4 ms 952 KB
#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(n);
	for(int j = 0; j < n; j++)
	{
		if(num&(1<<j))
		{
			now[j] = 1;
		}
		else
		{
			now[j] = 0;
		}
	}
	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))
		{
			int ii = i;
			vint now;
			for(int j = 0; j < n; j++)
			{
				now.pb(ii&1);
				ii>>=1;
			}
			for(auto x: now)
			{
				cout << x << " ";
			}
			return;
		}
	}
}
 
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:45: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]
   45 |  for(int i = 0; i < ranges.size(); i++)
      |                 ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 952 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 952 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -