File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` cpp
2+ #include < bits/stdc++.h>
3+ using namespace std ;
4+
5+ int N;
6+ map<int , set<int >> X, Y;
7+
8+ int main () {
9+ cin.tie(0)->sync_with_stdio(0);
10+
11+ cin >> N;
12+ for (int i = 0, x, y; i < N; i++) {
13+ cin >> x >> y;
14+ X[x].insert(y);
15+ Y[y].insert(x);
16+ }
17+
18+ if (min(X.size(), Y.size()) <= 3) return cout << 1, 0;
19+
20+ for (auto [x, v] : X) {
21+ for (int i : v) {
22+ Y[i].erase(x);
23+ if (Y[i].empty()) Y.erase(i);
24+ }
25+ if (Y.size() <= 2) return cout << 1, 0;
26+ for (int i : v) Y[i].insert(x);
27+ }
28+
29+ for (auto [y, v] : Y) {
30+ for (int i : v) {
31+ X[i].erase(y);
32+ if (X[i].empty()) X.erase(i);
33+ }
34+ if (X.size() <= 2) return cout << 1, 0;
35+ for (int i : v) X[i].insert(y);
36+ }
37+
38+ cout << 0;
39+
40+ }
41+ ```
You can’t perform that action at this time.
0 commit comments