#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
int main()
{
ll n;
cin >> n;
map<ll, vector<ll>> x;
map<ll, vector<ll>> y;
map<ll, ll> counts;
ll ans = 0;
for (int i = 0; i < n; i++)
{
ll a, b;
cin >> a >> b;
x[a].pb(b);
y[b].pb(a);
}
for (auto i : x)
{
ll elementsss = 0;
ll currsum = 0;
for (auto j : i.second)
{
int sz = y[j].size();
sz--;
currsum += sz;
elementsss++;
}
ans += currsum * (elementsss - 1);
}
cout << ans;
// x: 0 = 0, 1; 1 = 0 y: 0 = 0,1 1 = 0
// x: 0 = 2; 1 = 2;
// y: 0 = 2; 1 = 2;
// if found a coordinate sharing x/y find a coordinate in which it either shares y/x
// example: 0 1 ,0 2
/*
x..
...
x.x
*/
//
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
9 ms |
1416 KB |
Output is correct |
13 |
Correct |
9 ms |
1628 KB |
Output is correct |
14 |
Correct |
13 ms |
2140 KB |
Output is correct |
15 |
Correct |
136 ms |
8532 KB |
Output is correct |
16 |
Correct |
142 ms |
8864 KB |
Output is correct |
17 |
Correct |
142 ms |
8536 KB |
Output is correct |
18 |
Correct |
172 ms |
8620 KB |
Output is correct |
19 |
Correct |
386 ms |
14676 KB |
Output is correct |
20 |
Correct |
269 ms |
12116 KB |
Output is correct |
21 |
Correct |
397 ms |
15184 KB |
Output is correct |
22 |
Correct |
421 ms |
15444 KB |
Output is correct |