#include <bits/stdc++.h>
#define FOR( i, x, n, d ) for( int i = x; i <= n; i += d )
using namespace std;
const int N = 1e6;
int a[N], b[N], x[N], y[N], a2[N], b2[N], tim;
long long ans = 0;
int main()
{
// freopen("triangle.in", "r", stdin);
// freopen("triangle.out", "w", stdout);
int n; cin >> n;
set <int> st;
map <int, int> mp;
FOR( i, 1, n, 1 ) cin >> x[i] >> y[i], st.insert( x[i] ), st.insert( y[i] );
for( auto i : st ) mp[i] = ++ tim;
FOR( i, 1, n, 1 )
{
x[i] = mp[x[i]], y[i] = mp[y[i]];
a[x[i]] ++, b[y[i]] ++;
}
FOR( i, 1, n, 1 )
{
ans += ( a[x[i]] - 1 ) * ( b[y[i]] - 1 );
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
416 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 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 |
516 KB |
Output is correct |
12 |
Correct |
8 ms |
1564 KB |
Output is correct |
13 |
Correct |
9 ms |
1636 KB |
Output is correct |
14 |
Correct |
14 ms |
2108 KB |
Output is correct |
15 |
Correct |
115 ms |
6484 KB |
Output is correct |
16 |
Correct |
121 ms |
6976 KB |
Output is correct |
17 |
Correct |
114 ms |
6672 KB |
Output is correct |
18 |
Correct |
112 ms |
6484 KB |
Output is correct |
19 |
Correct |
307 ms |
11856 KB |
Output is correct |
20 |
Correct |
216 ms |
9552 KB |
Output is correct |
21 |
Correct |
325 ms |
12364 KB |
Output is correct |
22 |
Correct |
325 ms |
12372 KB |
Output is correct |