This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;
ll N, M;
vector<pii> v;
signed main()
{
ios::sync_with_stdio(0), cin.tie(0);
cin >> N >> M;
for (int i = 1; i <= M; i++)
{
int a, b;
cin >> a >> b;
v.emplace_back(pii{a, b});
}
if (N <= 15)
{
for (int mask = 0; mask < (1 << M); mask++)
{
bool valid[2] = {1, 1};
for (int i = 1; i <= N; i++)
{
bool exist[2] = {0, 0};
for (int j = 0; j < M; j++)
{
if ((v[j].F <= v[j].S && v[j].F <= i && i <= v[j].S) || (v[j].F > v[j].S && !(v[j].S < i && i < v[j].F)))
exist[(mask >> j) & 1] = 1;
}
valid[0] &= exist[0];
valid[1] &= exist[1];
}
if (valid[0] && valid[1])
{
for (int j = 0; j < M; j++)
cout << ((mask >> j) & 1);
cout << '\n';
return 0;
}
}
cout << "impossible\n";
}
else
{
}
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |