#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)
#define ff first
#define ss second
using ll = int64_t;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
vector<pair<int, int>> v(n);
map<int, int> x, y;
trav(p, v) {
cin >> p.ff >> p.ss;
++x[p.ff]; ++y[p.ss];
}
ll ans = 0;
trav(p, v) ans += 1ll * (x[p.ff] - 1) * (y[p.ss] - 1);
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
12 ms |
1024 KB |
Output is correct |
13 |
Correct |
11 ms |
1024 KB |
Output is correct |
14 |
Correct |
18 ms |
1408 KB |
Output is correct |
15 |
Correct |
129 ms |
6204 KB |
Output is correct |
16 |
Correct |
134 ms |
6520 KB |
Output is correct |
17 |
Correct |
124 ms |
6264 KB |
Output is correct |
18 |
Correct |
139 ms |
6264 KB |
Output is correct |
19 |
Correct |
323 ms |
11512 KB |
Output is correct |
20 |
Correct |
235 ms |
9336 KB |
Output is correct |
21 |
Correct |
360 ms |
12456 KB |
Output is correct |
22 |
Correct |
347 ms |
12152 KB |
Output is correct |