#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define ms(x) memset((x), -1, sizeof (x))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define fi first
#define se second
#define MASK(i) (1 << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
const int MAX = (int) 1e6 + 5;
const int MOD = (int) 1e9 + 7;
int n;
pii a[MAX];
namespace sub1{
bool check(){
return n <= 16;
}
int D[20], U[20], L[20], R[20], X[1000005], Y[1000005], ok[20], ok2 = 1;
void process(const int &i, const int &j){
pii x = a[i], y = a[j];
if (x.fi == y.fi && x.se > y.se) U[j] = 1;
if (x.fi == y.fi && x.se < y.se) D[j] = 1;
if (x.fi < y.fi && x.se == y.se) L[j] = 1;
if (x.fi > y.fi && x.se == y.se) R[j] = 1;
ok[i] = 1;
}
void solve(){
for (int msk = 1; msk < MASK(n); msk++){
for (int i = 0; i < n; i++){
D[i] = U[i] = L[i] = R[i] = X[a[i].fi] = Y[a[i].se] = ok[i] = 0;
ok2 = 1;
}
for (int i = 0; i < n; i++){
if (BIT(msk, i)){
X[a[i].fi]++;
Y[a[i].se]++;
if (X[a[i].fi] > 2) ok2 = 0;
if (Y[a[i].se] > 2) ok2 = 0;
for (int j = 0; j < n; j++){
if (i ^ j) process(i, j);
}
}
}
if (ok2){
bool ok3 = 1;
for (int i = 0; i < n; i++){
if ((U[i] && D[i]) || (R[i] && L[i]) || ok[i]) ok[i] = 1;
if (!ok[i]) ok3 = 0;
}
if (ok3){
for (int i = 0; i < n; i++){
if (BIT(msk, i)) cout << 1;
else cout << 0;
}
return;
}
}
}
}
}
namespace sub3{
bool check(){
bool ok[1000005];
memset(ok, 0, sizeof ok);
for (int i = 0; i < n; i++){
if (ok[a[i].fi]) return 0;
ok[a[i].fi] = 1;
}
return 1;
}
void solve(){
vector<pii> X[10005];
bool answer[n + 5];
for (int i = 0; i < n; i++){
X[a[i].se].emplace_back(a[i].fi, i);
}
for (int i = 1; i < 10005; i++){
if (X[i].size()){
int mx = 0, mn = 0;
for (int j = 0; j < (int)X[i].size(); j++){
if (X[i][mx].fi < X[i][j].fi) mx = j;
if (X[i][mn].fi > X[i][j].fi) mn = j;
}
answer[X[i][mx].se] = answer[X[i][mn].se] = 1;
}
}
for (int i = 0; i < n; i++) cout << answer[i];
}
}
signed main(){
#define name "slamp"
if (fopen(name".inp", "r")){
freopen(name".inp", "r", stdin);
freopen(name".out", "w", stdout);
}
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i].fi >> a[i].se;
if (sub1::check()) return sub1::solve(), 0;
if (sub3::check()) return sub3::solve(), 0;
return 0;
}
Compilation message (stderr)
Main.cpp: In function 'int main()':
Main.cpp:108:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
108 | freopen(name".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:109:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
109 | freopen(name".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~| # | 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... |