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/extc++.h"
using namespace std;
template <typename T>
void dbgh(const T& t) {
cerr << t << endl;
}
template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
cerr << t << " | ";
dbgh(u...);
}
#ifdef DEBUG
#define dbg(...) \
cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]" \
<< ": "; \
dbgh(__VA_ARGS__)
#else
#define cerr \
if (false) \
cerr
#define dbg(...)
#endif
#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())
void solve() {
int n, m;
cin >> n >> m;
int arr[m][2];
for (auto& [l, r] : arr) {
cin >> l >> r;
l--;
r--;
}
for (int i = 0; i < (1 << m); i++) {
int vis[n] {};
for (int j = 0; j < m; j++) {
int msk = 1 << ((i >> j) & 1);
auto [l, r] = arr[j];
if (l <= r) {
for (int k = l; k <= r; k++) {
vis[k] |= msk;
}
} else {
for (int k = l; k < n; k++) {
vis[k] |= msk;
}
for (int k = 0; k <= r; k++) {
vis[k] |= msk;
}
}
}
for (auto& a : vis) {
if (a != 3) {
goto loop;
}
}
for (int j = 0; j < m; j++) {
cout << ((i >> j) & 1);
}
cout << endl;
return;
loop:;
}
cout << "impossible" << endl;
}
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cin.exceptions(ios::failbit);
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... |