Skip to content

Commit 210dc71

Browse files
committed
solved 2171
1 parent 934a41a commit 210dc71

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

2000/2171/2171.cpp

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <unordered_set>
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
5+
typedef long long ll;
6+
typedef pair<int, int> pii;
7+
#define mp(a, b) make_pair(a, b)
8+
#define X first
9+
#define Y second
10+
11+
#define FOR(i, a, b) for (int i = a; i < b; i++)
12+
13+
int N, ans=0;
14+
ll bias = 1000000000;
15+
vector<pii> pts;
16+
unordered_set<ll> s;
17+
18+
ll toLL(ll x, ll y){
19+
return (x+bias)*2*bias + y+bias;
20+
}
21+
22+
int main() {
23+
ios::sync_with_stdio(false); cin.tie(NULL);
24+
cin>>N;
25+
FOR(i, 0, N){
26+
int x, y;
27+
cin>>x>>y;
28+
pts.push_back(mp(x, y));
29+
s.insert(toLL(x, y));
30+
}
31+
32+
sort(pts.begin(), pts.end());
33+
34+
FOR(i, 0, N) FOR(j, i+1, N){
35+
pii a = pts[i], b = pts[j];
36+
if(a.X >= b.X || a.Y >= b.Y) continue;
37+
if(s.find(toLL(a.X, b.Y)) != s.end() && s.find(toLL(b.X, a.Y)) != s.end()){
38+
++ans;
39+
}
40+
}
41+
42+
cout<<ans;
43+
44+
return 0;
45+
}

0 commit comments

Comments
 (0)