/// - Art -
#include <bits/stdc++.h>
#define el cout << '\n'
#define MASK(x) (1 << (x))
#define BIT(i, x) ((x) >> (i) & 1)
#define corved(x) ((BIT(0, x) && BIT(1, x)) || (BIT(2, x) && BIT(3, x)))
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define REV(i, b, a) for (int i = (b), _a = (a); i >= _a; --i)
#define REP(i, c) for (int i = 0, _c = (c); i < _c; ++i)
const int N = 1e6 + 7;
using namespace std;
pair<int, int> p[N];
vector<pair<int, int>> row[N], col[N];
int state[N];
struct Data {
int coord, sz;
bool type; /// 0/1: row/col
Data(int _coord = 0, int _sz = 0, bool _type = 0) {
coord = _coord; sz = _sz; type = _type;
}
bool operator() (Data &a, Data &b) {
return a.sz > b.sz;
}
};
bool lamp[N];
/// 0: Left, 1: Right
/// 2: Up, 3: Down
int main() {
#define name "slamp"
if (fopen(name".inp", "r")) {
freopen(name".inp", "r", stdin);
freopen(name".out", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
FOR (i, 1, n) {
int x, y;
cin >> x >> y;
p[i] = make_pair(x, y);
row[x].emplace_back(y, i);
col[y].emplace_back(x, i);
}
// sort(p + 1, p + n + 1);
// priority_queue<Data, vector<Data>> Q;
// FOR (x, 1, 1e6) if (!row[x].empty()) {
// row[x].emplace_back()
// }
FOR (y, 1, 1e6) {
sort(col[y].begin(), col[y].end());
}
FOR (x, 1, 1e6) if (!row[x].empty()) {
sort(row[x].begin(), row[x].end());
FOR (i, 1, row[x].size() - 2) {
int id = row[x][i].second;
state[id] |= MASK(0) | MASK(1);
}
lamp[row[x][0].second] = 1;
for (pair<int, int> &info : col[p[row[x][0].second].second]) {
int id = info.second;
if (info.first < x) {
state[id] |= MASK(2);
}
else if (info.first > x) {
state[id] |= MASK(3);
}
}
if (row[x].size() >= 2) {
lamp[row[x].back().second] = 1;
for (pair<int, int> &info : col[p[row[x].back().second].second]) {
int id = info.second;
if (info.first < x) {
state[id] |= MASK(2);
}
else if (info.first > x) {
state[id] |= MASK(3);
}
}
}
}
// cout << bitset<4>(state[7]), el;
FOR (i, 1, n) if (lamp[i] && corved(state[i])) {
lamp[i] = 0;
int x = p[i].first, y = p[i].second;
for (pair<int, int> &info : row[x]) {
int id = info.second;
if (info.first < y) {
state[id] ^= MASK(0);
}
else if (info.first > y) {
state[id] ^= MASK(1);
}
}
for (pair<int, int> &info : col[y]) {
int id = info.second;
if (info.first < x) {
state[id] ^= MASK(2);
}
else if (info.first > x) {
state[id] ^= MASK(3);
}
}
}
FOR (i, 1, n) {
cout << (lamp[i] || !corved(state[i]));
} el;
return 0;
}
/*
9
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
*/
/*
8
1 5
3 5
6 7
6 5
6 1
3 7
6 3
5 5
*/
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:45:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
45 | freopen(name".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:46:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
46 | 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... |