Skip to content

Commit 9fde73f

Browse files
authored
Merge pull request #1572 from AlgorithmWithGod/khj20006
[20251203] BOJ / G4 / 감시 카메라 / 권혁준
2 parents ddce5bc + 0306ab1 commit 9fde73f

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
```

0 commit comments

Comments
 (0)