#include <bits/stdc++.h>
using namespace std;
// cartesian tree
/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pd_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Tree;
*/
// pragma
/*#pragma GCC optimize("O3")
#pragma GCC target("sse4")
*/
// defines
#define int long long
#define double long double
#define pb push_back
#define FOR(i, a, b) for(int i=a;i<(b);i++)
#define FORD(i, a, b) for(int i=(b)-1;i>=a;i--)
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define mp make_pair
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// consts
const int MOD = 1e9+7;
const int oo = 1e9;
const int OO = 1e18;
const double eps = 1e-9;
const double PI = 4.0 * atan(1.0);
void solve();
signed main() {
fast_io();
solve();
return 0;
}
////////////////////42////////////////////
int n, X[400000], Y[400000];
void solve() {
cin>>n;
for(int i=0;i<n;i++)cin>>X[i]>>Y[i];
map<int, int>x,y;
for(int i=0;i<n;i++)x[X[i]]++,y[Y[i]]++;
int ans=0;
for(int i=0;i<n;i++)ans+=(x[X[i]]-1LL)*(y[Y[i]]-1LL);
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
444 KB |
Output is correct |
3 |
Correct |
2 ms |
444 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
520 KB |
Output is correct |
7 |
Correct |
2 ms |
520 KB |
Output is correct |
8 |
Correct |
2 ms |
528 KB |
Output is correct |
9 |
Correct |
2 ms |
532 KB |
Output is correct |
10 |
Correct |
3 ms |
592 KB |
Output is correct |
11 |
Correct |
3 ms |
640 KB |
Output is correct |
12 |
Correct |
14 ms |
1572 KB |
Output is correct |
13 |
Correct |
9 ms |
1864 KB |
Output is correct |
14 |
Correct |
14 ms |
2476 KB |
Output is correct |
15 |
Correct |
184 ms |
8872 KB |
Output is correct |
16 |
Correct |
196 ms |
11408 KB |
Output is correct |
17 |
Correct |
193 ms |
13536 KB |
Output is correct |
18 |
Correct |
201 ms |
15740 KB |
Output is correct |
19 |
Correct |
554 ms |
24668 KB |
Output is correct |
20 |
Correct |
377 ms |
27868 KB |
Output is correct |
21 |
Correct |
660 ms |
35876 KB |
Output is correct |
22 |
Correct |
647 ms |
42272 KB |
Output is correct |