#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define ff first
#define ss second
const int mxn = 3e5 + 10;
int n, id[mxn], s = 1;
map<int, int> mp;
vector<vi> x;
vector<vi> y;
pii p[mxn];
int main() {
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> p[i].ff >> p[i].ss;
id[i] = i;
mp[p[i].ff];
mp[p[i].ss];
}
for(auto &t : mp) {
t.ss = s;
s++;
}
x.resize(s);
y.resize(s);
for(int i = 1; i <= n; i++) {
p[i].ff = mp[p[i].ff];
p[i].ss = mp[p[i].ss];
x[p[i].ff].push_back(i);
y[p[i].ss].push_back(i);
}
int ans = 0;
for(int i = 1; i <= n; i++) {
int X = p[i].ff, Y = p[i].ss;
int chx = x[X].size() - 1;
int chy = y[Y].size() - 1;
ans += chx * chy;
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
10 ms |
1884 KB |
Output is correct |
13 |
Correct |
15 ms |
1884 KB |
Output is correct |
14 |
Correct |
15 ms |
2652 KB |
Output is correct |
15 |
Correct |
138 ms |
10332 KB |
Output is correct |
16 |
Correct |
151 ms |
10844 KB |
Output is correct |
17 |
Correct |
140 ms |
10344 KB |
Output is correct |
18 |
Correct |
142 ms |
10332 KB |
Output is correct |
19 |
Correct |
392 ms |
17488 KB |
Output is correct |
20 |
Correct |
282 ms |
14704 KB |
Output is correct |
21 |
Correct |
444 ms |
18256 KB |
Output is correct |
22 |
Correct |
411 ms |
18456 KB |
Output is correct |