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>
using namespace std;
const int N = 16;
int l[N], r[N];
bitset <N> ps[2];
int main()
{
int n, m; cin >> n >> m;
for (int i = 0; i < m; i++) cin >> l[i] >> r[i], l[i]--, r[i]--;
for (int mask = 0; mask < (1 << m); mask++) {
ps[0] = ps[1] = 0;
for (int i = 0; i < m; i++) {
int L = l[i];
while (L != r[i])
ps[(mask>>i) & 1][L] = 1, L = (L + 1) % n;
ps[(mask>>i)&1][r[i]] = 1;
}
bool flag = 1;
for (int i = 0; i < n; i++) flag &= ps[0][i] & ps[1][i];
if (flag) {
for (int i = 0; i < m; i++) cout << ((mask>>i) & 1);
cout << "\n";
return 0;
}
}
cout << "impossible\n";
return 0;
}
# | 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... |