이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |