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;
typedef long long ll;
int N, M;
vector<pair<int, int>> wires;
bool can(int msk) {
vector<vector<bool>> cov(2, vector<bool>(N, 0));
for (int i = M-1, j = 0; i >= 0; i--, j++) {
bool which = msk & (1 << i);
for (int k = wires[j].first; k != wires[j].second; (k+=1)%=N) {
cov[which][k] = 1;
}
cov[which][wires[j].second] = 1;
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < 2; j++) {
if (!cov[j][i]) return false;
}
}
return true;
}
void solve() {
cin >> N >> M;
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
wires.push_back({--a, --b});
}
for (int msk = 0; msk < (1 << M); msk++) {
if (can(msk)) {
for (int i = M-1; i >= 0; i--) {
cout << (1 & (msk >> i));
}
return;
}
}
cout << "impossible";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
}
# | 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... |