//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define int long long
using namespace std;
void dout() {
cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
cerr << H << ' ';
dout(T...);
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
const int N = 3e5 + 3;
int n, ans;
vector <pii> v;
map <pii, int> q;
map <int, int> x, y;
void solve(int tc) {
cin >> n;
for (int i = 0; i < n; i++) {
pii p;
cin >> p.fi >> p.se;
v.pb(p);
}
sort(v.begin(), v.end());
for (int i = 0; i < n; i++) {
x[v[i].fi]++;
y[v[i].se]++;
q[v[i]]++;
}
for (int i = 0; i < n; i++) {
ans += (x[v[i].fi] - q[v[i]]) * (y[v[i].se] - q[v[i]]);
}
cout << ans;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int tc = 1;
// cin >> tc;
for (int i = 0; i < tc; i++) {
solve(i);
// cleanup();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
416 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
388 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
504 KB |
Output is correct |
12 |
Correct |
16 ms |
1912 KB |
Output is correct |
13 |
Correct |
15 ms |
1912 KB |
Output is correct |
14 |
Correct |
19 ms |
2424 KB |
Output is correct |
15 |
Correct |
225 ms |
14312 KB |
Output is correct |
16 |
Correct |
208 ms |
15208 KB |
Output is correct |
17 |
Correct |
192 ms |
14184 KB |
Output is correct |
18 |
Correct |
199 ms |
14284 KB |
Output is correct |
19 |
Correct |
572 ms |
32344 KB |
Output is correct |
20 |
Correct |
392 ms |
24416 KB |
Output is correct |
21 |
Correct |
647 ms |
34360 KB |
Output is correct |
22 |
Correct |
578 ms |
34516 KB |
Output is correct |