#include <bits/stdc++.h>
using namespace std;
#define ForUp(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define ForDown(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define all(a) (a).begin(), (a).end()
using ll = long long;
const int N = 1e6 + 24;
int n, x[N], y[N];
namespace sub12 {
bool check() { return n <= 16; }
int c[N], cntx[N], cnty[N];
void solve() {
int res = 0; ForUp (mask, 0, (1 << n) - 1) {
ForUp (i, 1, n) c[i] = (mask >> (i - 1)) & 1;
bool valid = 1;
ForUp (i, 1, n) cntx[x[i]] = cnty[y[i]] = 0;
ForUp (i, 1, n) if (c[i]) {
cntx[x[i]]++; cnty[y[i]]++;
}
ForUp (i, 1, n) {
if (cntx[x[i]] > 2 || cnty[y[i]] > 2) {
valid = 0;
break;
}
}
if (!valid) continue;
ForUp (i, 1, n) if (!c[i]) {
bool L = 0, R = 0;
ForUp (j, 1, n) if (c[j] && x[i] == x[j]) {
if (y[i] > y[j]) L = 1;
else R = 1;
}
if (L && R) continue;
L = 0, R = 0;
ForUp (j, 1, n) if (c[j] && y[i] == y[j]) {
if (x[i] > x[j]) L = 1;
else R = 1;
}
if (L && R) continue;
valid = 0; break;
}
if (!valid) continue;
res = mask;
break;
}
ForUp (i, 1, n) {
cout << ((res >> (i - 1)) & 1);
}
cout << '\n';
}
};
void solve() {
cin >> n; ForUp (i, 1, n) {
cin >> x[i] >> y[i];
}
if (sub12::check()) return sub12::solve();
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int T = 1; // cin >> T;
while (T--) {
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... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |