#include <bits/stdc++.h>
using namespace std;
template<typename A, typename B>
string to_string(pair<A, B>);
string to_string(string S) {
return '"' + S + '"';
}
string to_string(const char* c) {
return to_string(string(c));
}
string to_string(bool b) {
return (b ? "true" : "false");
}
template<size_t T>
string to_string(bitset<T> bs) {
return bs.to_string();
}
string to_string(vector<bool> v) {
string res = "{";
for (int i = 0; i < int(v.size()); ++i) {
if (int(res.size()) > 1) {
res += ", ";
}
res += to_string(v[i]);
}
return res + "}";
}
template<typename T>
string to_string(T v) {
string res = "{";
for (auto e : v) {
if (int(res.size()) > 1) {
res += ", ";
}
res += to_string(e);
}
return res + "}";
}
template<typename A, typename B>
string to_string(pair<A, B> p) {
return '(' + to_string(p.first) + ", " + to_string(p.second) + ')';
}
void debug_out() {
cerr << endl;
}
template<typename H, typename... T>
void debug_out(H head, T... tail) {
cerr << " " << to_string(head);
debug_out(tail...);
}
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) void(37)
#endif
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N;
cin >> N;
vector<int> X(N), Y(N);
for (int i = 0; i < N; ++i) {
cin >> X[i] >> Y[i];
--X[i], --Y[i];
}
#ifdef LOCAL
const int MAX = int(30);
#else
const int MAX = int(1e6);
#endif
vector<vector<int>> xs(MAX), ys(MAX);
for (int i = 0; i < N; ++i) {
xs[X[i]].push_back(i);
ys[Y[i]].push_back(i);
}
vector<int> xid(N), yid(N);
for (int i = 0; i < MAX; ++i) {
sort(xs[i].begin(), xs[i].end(), [&](int x, int y) {
return Y[x] < Y[y];
});
sort(ys[i].begin(), ys[i].end(), [&](int x, int y) {
return X[x] < X[y];
});
for (int j = 0; j < int(xs[i].size()); ++j) {
xid[xs[i][j]] = j;
}
for (int j = 0; j < int(ys[i].size()); ++j) {
yid[ys[i][j]] = j;
}
}
vector<bool> top(N), bot(N);
vector<int> min_row(MAX, -1);
vector<int> max_row(MAX, -1);
vector<int> rem;
auto Add = [&](int i, bool type) {
debug(i, type);
if (type) {
top[i] = true;
} else {
bot[i] = true;
}
int& mn = min_row[Y[i]];
int& mx = max_row[Y[i]];
if (mn == -1) {
mn = mx = i;
} else if (X[mn] > X[i]) {
debug(mn, mx, X[mn], X[i]);
if (mx != mn) rem.push_back(mn);
mn = i;
} else if (X[mx] < X[i]) {
debug(mx, mn, X[mx], X[i]);
if (mx != mn) rem.push_back(mx);
mx = i;
}
if (mn != i && mx != i) {
debug("!used", i);
rem.push_back(i);
}
};
for (int i = 0; i < MAX; ++i) {
if (xs[i].empty()) continue;
Add(xs[i][0], false);
Add(xs[i].back(), true);
}
debug(top, bot, rem);
for (int it = 0; it < int(rem.size()); ++it) {
int i = rem[it];
debug(i, bool(top[i]), bool(bot[i]));
if (top[i] && bot[i]) {
top[i] = bot[i] = false;
continue;
}
if (top[i]) {
top[i] = false;
Add(xs[X[i]][xid[i] - 1], true);
} else if (bot[i]) {
bot[i] = false;
Add(xs[X[i]][xid[i] + 1], false);
}
}
for (int i = 0; i < N; ++i) {
cout << (bot[i] || top[i]);
}
cout << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
55132 KB |
Output is correct |
2 |
Correct |
19 ms |
55176 KB |
Output is correct |
3 |
Correct |
19 ms |
55132 KB |
Output is correct |
4 |
Correct |
20 ms |
55136 KB |
Output is correct |
5 |
Correct |
18 ms |
55132 KB |
Output is correct |
6 |
Correct |
18 ms |
55132 KB |
Output is correct |
7 |
Correct |
18 ms |
55132 KB |
Output is correct |
8 |
Correct |
22 ms |
55196 KB |
Output is correct |
9 |
Correct |
20 ms |
55132 KB |
Output is correct |
10 |
Correct |
21 ms |
55204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
55132 KB |
Output is correct |
2 |
Correct |
19 ms |
55176 KB |
Output is correct |
3 |
Correct |
19 ms |
55132 KB |
Output is correct |
4 |
Correct |
20 ms |
55136 KB |
Output is correct |
5 |
Correct |
18 ms |
55132 KB |
Output is correct |
6 |
Correct |
18 ms |
55132 KB |
Output is correct |
7 |
Correct |
18 ms |
55132 KB |
Output is correct |
8 |
Correct |
22 ms |
55196 KB |
Output is correct |
9 |
Correct |
20 ms |
55132 KB |
Output is correct |
10 |
Correct |
21 ms |
55204 KB |
Output is correct |
11 |
Correct |
19 ms |
55120 KB |
Output is correct |
12 |
Correct |
19 ms |
55128 KB |
Output is correct |
13 |
Correct |
23 ms |
55132 KB |
Output is correct |
14 |
Correct |
23 ms |
55128 KB |
Output is correct |
15 |
Correct |
19 ms |
55132 KB |
Output is correct |
16 |
Correct |
21 ms |
55132 KB |
Output is correct |
17 |
Correct |
20 ms |
55132 KB |
Output is correct |
18 |
Correct |
20 ms |
55132 KB |
Output is correct |
19 |
Correct |
19 ms |
55128 KB |
Output is correct |
20 |
Correct |
20 ms |
55112 KB |
Output is correct |
21 |
Correct |
19 ms |
55132 KB |
Output is correct |
22 |
Correct |
21 ms |
55244 KB |
Output is correct |
23 |
Correct |
23 ms |
55136 KB |
Output is correct |
24 |
Correct |
22 ms |
55132 KB |
Output is correct |
25 |
Correct |
19 ms |
55128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
58716 KB |
Output is correct |
2 |
Correct |
36 ms |
59308 KB |
Output is correct |
3 |
Correct |
77 ms |
68556 KB |
Output is correct |
4 |
Correct |
140 ms |
80280 KB |
Output is correct |
5 |
Correct |
42 ms |
60124 KB |
Output is correct |
6 |
Correct |
22 ms |
56156 KB |
Output is correct |
7 |
Correct |
124 ms |
77768 KB |
Output is correct |
8 |
Correct |
92 ms |
72452 KB |
Output is correct |
9 |
Correct |
203 ms |
89288 KB |
Output is correct |
10 |
Correct |
148 ms |
82632 KB |
Output is correct |
11 |
Correct |
189 ms |
89912 KB |
Output is correct |
12 |
Correct |
195 ms |
89892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
433 ms |
123316 KB |
Output is correct |
2 |
Correct |
475 ms |
122264 KB |
Output is correct |
3 |
Correct |
516 ms |
122984 KB |
Output is correct |
4 |
Correct |
476 ms |
122156 KB |
Output is correct |
5 |
Correct |
455 ms |
123144 KB |
Output is correct |
6 |
Correct |
751 ms |
128832 KB |
Output is correct |
7 |
Correct |
773 ms |
128824 KB |
Output is correct |
8 |
Correct |
745 ms |
128968 KB |
Output is correct |
9 |
Correct |
706 ms |
128972 KB |
Output is correct |
10 |
Correct |
708 ms |
129040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
55132 KB |
Output is correct |
2 |
Correct |
19 ms |
55176 KB |
Output is correct |
3 |
Correct |
19 ms |
55132 KB |
Output is correct |
4 |
Correct |
20 ms |
55136 KB |
Output is correct |
5 |
Correct |
18 ms |
55132 KB |
Output is correct |
6 |
Correct |
18 ms |
55132 KB |
Output is correct |
7 |
Correct |
18 ms |
55132 KB |
Output is correct |
8 |
Correct |
22 ms |
55196 KB |
Output is correct |
9 |
Correct |
20 ms |
55132 KB |
Output is correct |
10 |
Correct |
21 ms |
55204 KB |
Output is correct |
11 |
Correct |
19 ms |
55120 KB |
Output is correct |
12 |
Correct |
19 ms |
55128 KB |
Output is correct |
13 |
Correct |
23 ms |
55132 KB |
Output is correct |
14 |
Correct |
23 ms |
55128 KB |
Output is correct |
15 |
Correct |
19 ms |
55132 KB |
Output is correct |
16 |
Correct |
21 ms |
55132 KB |
Output is correct |
17 |
Correct |
20 ms |
55132 KB |
Output is correct |
18 |
Correct |
20 ms |
55132 KB |
Output is correct |
19 |
Correct |
19 ms |
55128 KB |
Output is correct |
20 |
Correct |
20 ms |
55112 KB |
Output is correct |
21 |
Correct |
19 ms |
55132 KB |
Output is correct |
22 |
Correct |
21 ms |
55244 KB |
Output is correct |
23 |
Correct |
23 ms |
55136 KB |
Output is correct |
24 |
Correct |
22 ms |
55132 KB |
Output is correct |
25 |
Correct |
19 ms |
55128 KB |
Output is correct |
26 |
Correct |
22 ms |
55644 KB |
Output is correct |
27 |
Correct |
23 ms |
55640 KB |
Output is correct |
28 |
Correct |
20 ms |
55388 KB |
Output is correct |
29 |
Correct |
20 ms |
55388 KB |
Output is correct |
30 |
Correct |
21 ms |
55388 KB |
Output is correct |
31 |
Correct |
20 ms |
55388 KB |
Output is correct |
32 |
Correct |
21 ms |
55388 KB |
Output is correct |
33 |
Correct |
24 ms |
55388 KB |
Output is correct |
34 |
Correct |
21 ms |
55384 KB |
Output is correct |
35 |
Correct |
21 ms |
55388 KB |
Output is correct |
36 |
Correct |
20 ms |
55420 KB |
Output is correct |
37 |
Correct |
20 ms |
55496 KB |
Output is correct |
38 |
Correct |
20 ms |
55384 KB |
Output is correct |
39 |
Correct |
21 ms |
55388 KB |
Output is correct |
40 |
Correct |
20 ms |
55388 KB |
Output is correct |
41 |
Correct |
20 ms |
55332 KB |
Output is correct |
42 |
Correct |
20 ms |
55344 KB |
Output is correct |
43 |
Correct |
20 ms |
55388 KB |
Output is correct |
44 |
Correct |
20 ms |
55388 KB |
Output is correct |
45 |
Correct |
20 ms |
55388 KB |
Output is correct |
46 |
Correct |
20 ms |
55384 KB |
Output is correct |
47 |
Correct |
21 ms |
55500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
55132 KB |
Output is correct |
2 |
Correct |
19 ms |
55176 KB |
Output is correct |
3 |
Correct |
19 ms |
55132 KB |
Output is correct |
4 |
Correct |
20 ms |
55136 KB |
Output is correct |
5 |
Correct |
18 ms |
55132 KB |
Output is correct |
6 |
Correct |
18 ms |
55132 KB |
Output is correct |
7 |
Correct |
18 ms |
55132 KB |
Output is correct |
8 |
Correct |
22 ms |
55196 KB |
Output is correct |
9 |
Correct |
20 ms |
55132 KB |
Output is correct |
10 |
Correct |
21 ms |
55204 KB |
Output is correct |
11 |
Correct |
19 ms |
55120 KB |
Output is correct |
12 |
Correct |
19 ms |
55128 KB |
Output is correct |
13 |
Correct |
23 ms |
55132 KB |
Output is correct |
14 |
Correct |
23 ms |
55128 KB |
Output is correct |
15 |
Correct |
19 ms |
55132 KB |
Output is correct |
16 |
Correct |
21 ms |
55132 KB |
Output is correct |
17 |
Correct |
20 ms |
55132 KB |
Output is correct |
18 |
Correct |
20 ms |
55132 KB |
Output is correct |
19 |
Correct |
19 ms |
55128 KB |
Output is correct |
20 |
Correct |
20 ms |
55112 KB |
Output is correct |
21 |
Correct |
19 ms |
55132 KB |
Output is correct |
22 |
Correct |
21 ms |
55244 KB |
Output is correct |
23 |
Correct |
23 ms |
55136 KB |
Output is correct |
24 |
Correct |
22 ms |
55132 KB |
Output is correct |
25 |
Correct |
19 ms |
55128 KB |
Output is correct |
26 |
Correct |
22 ms |
55644 KB |
Output is correct |
27 |
Correct |
23 ms |
55640 KB |
Output is correct |
28 |
Correct |
20 ms |
55388 KB |
Output is correct |
29 |
Correct |
20 ms |
55388 KB |
Output is correct |
30 |
Correct |
21 ms |
55388 KB |
Output is correct |
31 |
Correct |
20 ms |
55388 KB |
Output is correct |
32 |
Correct |
21 ms |
55388 KB |
Output is correct |
33 |
Correct |
24 ms |
55388 KB |
Output is correct |
34 |
Correct |
21 ms |
55384 KB |
Output is correct |
35 |
Correct |
21 ms |
55388 KB |
Output is correct |
36 |
Correct |
20 ms |
55420 KB |
Output is correct |
37 |
Correct |
20 ms |
55496 KB |
Output is correct |
38 |
Correct |
20 ms |
55384 KB |
Output is correct |
39 |
Correct |
21 ms |
55388 KB |
Output is correct |
40 |
Correct |
20 ms |
55388 KB |
Output is correct |
41 |
Correct |
20 ms |
55332 KB |
Output is correct |
42 |
Correct |
20 ms |
55344 KB |
Output is correct |
43 |
Correct |
20 ms |
55388 KB |
Output is correct |
44 |
Correct |
20 ms |
55388 KB |
Output is correct |
45 |
Correct |
20 ms |
55388 KB |
Output is correct |
46 |
Correct |
20 ms |
55384 KB |
Output is correct |
47 |
Correct |
21 ms |
55500 KB |
Output is correct |
48 |
Correct |
75 ms |
64148 KB |
Output is correct |
49 |
Correct |
78 ms |
64232 KB |
Output is correct |
50 |
Correct |
91 ms |
62212 KB |
Output is correct |
51 |
Correct |
95 ms |
62292 KB |
Output is correct |
52 |
Correct |
54 ms |
60000 KB |
Output is correct |
53 |
Correct |
53 ms |
60092 KB |
Output is correct |
54 |
Correct |
53 ms |
59984 KB |
Output is correct |
55 |
Correct |
48 ms |
59984 KB |
Output is correct |
56 |
Correct |
50 ms |
60200 KB |
Output is correct |
57 |
Correct |
48 ms |
59984 KB |
Output is correct |
58 |
Correct |
53 ms |
60108 KB |
Output is correct |
59 |
Correct |
50 ms |
60124 KB |
Output is correct |
60 |
Correct |
48 ms |
60048 KB |
Output is correct |
61 |
Correct |
46 ms |
59988 KB |
Output is correct |
62 |
Correct |
47 ms |
60020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
55132 KB |
Output is correct |
2 |
Correct |
19 ms |
55176 KB |
Output is correct |
3 |
Correct |
19 ms |
55132 KB |
Output is correct |
4 |
Correct |
20 ms |
55136 KB |
Output is correct |
5 |
Correct |
18 ms |
55132 KB |
Output is correct |
6 |
Correct |
18 ms |
55132 KB |
Output is correct |
7 |
Correct |
18 ms |
55132 KB |
Output is correct |
8 |
Correct |
22 ms |
55196 KB |
Output is correct |
9 |
Correct |
20 ms |
55132 KB |
Output is correct |
10 |
Correct |
21 ms |
55204 KB |
Output is correct |
11 |
Correct |
19 ms |
55120 KB |
Output is correct |
12 |
Correct |
19 ms |
55128 KB |
Output is correct |
13 |
Correct |
23 ms |
55132 KB |
Output is correct |
14 |
Correct |
23 ms |
55128 KB |
Output is correct |
15 |
Correct |
19 ms |
55132 KB |
Output is correct |
16 |
Correct |
21 ms |
55132 KB |
Output is correct |
17 |
Correct |
20 ms |
55132 KB |
Output is correct |
18 |
Correct |
20 ms |
55132 KB |
Output is correct |
19 |
Correct |
19 ms |
55128 KB |
Output is correct |
20 |
Correct |
20 ms |
55112 KB |
Output is correct |
21 |
Correct |
19 ms |
55132 KB |
Output is correct |
22 |
Correct |
21 ms |
55244 KB |
Output is correct |
23 |
Correct |
23 ms |
55136 KB |
Output is correct |
24 |
Correct |
22 ms |
55132 KB |
Output is correct |
25 |
Correct |
19 ms |
55128 KB |
Output is correct |
26 |
Correct |
34 ms |
58716 KB |
Output is correct |
27 |
Correct |
36 ms |
59308 KB |
Output is correct |
28 |
Correct |
77 ms |
68556 KB |
Output is correct |
29 |
Correct |
140 ms |
80280 KB |
Output is correct |
30 |
Correct |
42 ms |
60124 KB |
Output is correct |
31 |
Correct |
22 ms |
56156 KB |
Output is correct |
32 |
Correct |
124 ms |
77768 KB |
Output is correct |
33 |
Correct |
92 ms |
72452 KB |
Output is correct |
34 |
Correct |
203 ms |
89288 KB |
Output is correct |
35 |
Correct |
148 ms |
82632 KB |
Output is correct |
36 |
Correct |
189 ms |
89912 KB |
Output is correct |
37 |
Correct |
195 ms |
89892 KB |
Output is correct |
38 |
Correct |
433 ms |
123316 KB |
Output is correct |
39 |
Correct |
475 ms |
122264 KB |
Output is correct |
40 |
Correct |
516 ms |
122984 KB |
Output is correct |
41 |
Correct |
476 ms |
122156 KB |
Output is correct |
42 |
Correct |
455 ms |
123144 KB |
Output is correct |
43 |
Correct |
751 ms |
128832 KB |
Output is correct |
44 |
Correct |
773 ms |
128824 KB |
Output is correct |
45 |
Correct |
745 ms |
128968 KB |
Output is correct |
46 |
Correct |
706 ms |
128972 KB |
Output is correct |
47 |
Correct |
708 ms |
129040 KB |
Output is correct |
48 |
Correct |
22 ms |
55644 KB |
Output is correct |
49 |
Correct |
23 ms |
55640 KB |
Output is correct |
50 |
Correct |
20 ms |
55388 KB |
Output is correct |
51 |
Correct |
20 ms |
55388 KB |
Output is correct |
52 |
Correct |
21 ms |
55388 KB |
Output is correct |
53 |
Correct |
20 ms |
55388 KB |
Output is correct |
54 |
Correct |
21 ms |
55388 KB |
Output is correct |
55 |
Correct |
24 ms |
55388 KB |
Output is correct |
56 |
Correct |
21 ms |
55384 KB |
Output is correct |
57 |
Correct |
21 ms |
55388 KB |
Output is correct |
58 |
Correct |
20 ms |
55420 KB |
Output is correct |
59 |
Correct |
20 ms |
55496 KB |
Output is correct |
60 |
Correct |
20 ms |
55384 KB |
Output is correct |
61 |
Correct |
21 ms |
55388 KB |
Output is correct |
62 |
Correct |
20 ms |
55388 KB |
Output is correct |
63 |
Correct |
20 ms |
55332 KB |
Output is correct |
64 |
Correct |
20 ms |
55344 KB |
Output is correct |
65 |
Correct |
20 ms |
55388 KB |
Output is correct |
66 |
Correct |
20 ms |
55388 KB |
Output is correct |
67 |
Correct |
20 ms |
55388 KB |
Output is correct |
68 |
Correct |
20 ms |
55384 KB |
Output is correct |
69 |
Correct |
21 ms |
55500 KB |
Output is correct |
70 |
Correct |
75 ms |
64148 KB |
Output is correct |
71 |
Correct |
78 ms |
64232 KB |
Output is correct |
72 |
Correct |
91 ms |
62212 KB |
Output is correct |
73 |
Correct |
95 ms |
62292 KB |
Output is correct |
74 |
Correct |
54 ms |
60000 KB |
Output is correct |
75 |
Correct |
53 ms |
60092 KB |
Output is correct |
76 |
Correct |
53 ms |
59984 KB |
Output is correct |
77 |
Correct |
48 ms |
59984 KB |
Output is correct |
78 |
Correct |
50 ms |
60200 KB |
Output is correct |
79 |
Correct |
48 ms |
59984 KB |
Output is correct |
80 |
Correct |
53 ms |
60108 KB |
Output is correct |
81 |
Correct |
50 ms |
60124 KB |
Output is correct |
82 |
Correct |
48 ms |
60048 KB |
Output is correct |
83 |
Correct |
46 ms |
59988 KB |
Output is correct |
84 |
Correct |
47 ms |
60020 KB |
Output is correct |
85 |
Correct |
18 ms |
55132 KB |
Output is correct |
86 |
Correct |
19 ms |
55132 KB |
Output is correct |
87 |
Correct |
19 ms |
55132 KB |
Output is correct |
88 |
Correct |
672 ms |
125576 KB |
Output is correct |
89 |
Correct |
607 ms |
125988 KB |
Output is correct |
90 |
Correct |
642 ms |
125648 KB |
Output is correct |
91 |
Correct |
511 ms |
102248 KB |
Output is correct |
92 |
Correct |
517 ms |
102260 KB |
Output is correct |
93 |
Correct |
506 ms |
102348 KB |
Output is correct |
94 |
Correct |
454 ms |
101348 KB |
Output is correct |
95 |
Correct |
430 ms |
101564 KB |
Output is correct |
96 |
Correct |
462 ms |
101536 KB |
Output is correct |
97 |
Correct |
395 ms |
101572 KB |
Output is correct |
98 |
Correct |
424 ms |
101588 KB |
Output is correct |
99 |
Correct |
426 ms |
101568 KB |
Output is correct |
100 |
Correct |
333 ms |
98756 KB |
Output is correct |
101 |
Correct |
347 ms |
98756 KB |
Output is correct |
102 |
Correct |
329 ms |
98708 KB |
Output is correct |
103 |
Correct |
377 ms |
98504 KB |
Output is correct |
104 |
Correct |
315 ms |
98616 KB |
Output is correct |
105 |
Correct |
321 ms |
98632 KB |
Output is correct |
106 |
Correct |
340 ms |
96216 KB |
Output is correct |
107 |
Correct |
321 ms |
96028 KB |
Output is correct |