#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
pair<int, int> star[300005];
map<int, int> x, y;
int main() {
cin >> n;
for(int i = 0; i < n; i++) {
cin >> star[i].first >> star[i].second;
//cout << star[i].first << " " << star[i].second << endl;
if(x.count(star[i].first) > 0) {
int now = x.find(star[i].first) -> second;
x.erase(star[i].first);
x.insert({star[i].first, now + 1});
//cout << "x" << now << endl;
}
else {
x.insert({star[i].first, 1});
}
if(y.count(star[i].second) > 0) {
int now = y.find(star[i].second) -> second;
y.erase(star[i].second);
y.insert({star[i].second, now + 1});
//cout << "y" << now << endl;
}
else {
y.insert({star[i].second, 1});
}
}
ll ans = 0;
for(int i = 0; i < n; i++) {
int hor = x.find(star[i].first) -> second;
hor--;
int ver = y.find(star[i].second) -> second;
ver--;
ans += 1ll * ver * hor;
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
304 KB |
Output is correct |
12 |
Correct |
14 ms |
964 KB |
Output is correct |
13 |
Correct |
15 ms |
964 KB |
Output is correct |
14 |
Correct |
18 ms |
1384 KB |
Output is correct |
15 |
Correct |
204 ms |
6140 KB |
Output is correct |
16 |
Correct |
229 ms |
6336 KB |
Output is correct |
17 |
Correct |
220 ms |
6188 KB |
Output is correct |
18 |
Correct |
210 ms |
6184 KB |
Output is correct |
19 |
Correct |
629 ms |
11460 KB |
Output is correct |
20 |
Correct |
431 ms |
9220 KB |
Output is correct |
21 |
Correct |
691 ms |
11988 KB |
Output is correct |
22 |
Correct |
664 ms |
11972 KB |
Output is correct |