//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define F first
#define S second
#define ull unsigned long long
#define db double
#define ldb long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;
const int N = 500001;
using namespace std;
using namespace __gnu_pbds;
ll n, m, a, b, c, d, e;
map <pair <ll, ll>, ll> cnt;
pair <ll, ll> p[N];
ll gcd (ll a, ll b){while (a > 0 && b > 0){if (a >= b){a %= b;}else{b %= a;}}return a + b;}
ll binpow (ll a, ll b){
a %= mod;if (b == 0){return 1;}
else if (b % 2 == 1){
return binpow (a, b - 1) % mod * a % mod;
}
else{
ll t = binpow (a, b / 2) % mod;
return t * t % mod;
}
}
signed main (){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++){
cin >> p[i].first >> p[i].second;
cnt[{1, p[i].first}]++;
cnt[{2, p[i].second}]++;
}
for (int i = 1; i <= n; i++){
a += (cnt[{1, p[i].first}] - 1) * (cnt[{2, p[i].second}] - 1);
}
cout << a;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
5 ms |
1364 KB |
Output is correct |
13 |
Correct |
6 ms |
1364 KB |
Output is correct |
14 |
Correct |
9 ms |
1876 KB |
Output is correct |
15 |
Correct |
101 ms |
8524 KB |
Output is correct |
16 |
Correct |
125 ms |
8780 KB |
Output is correct |
17 |
Correct |
105 ms |
8596 KB |
Output is correct |
18 |
Correct |
102 ms |
8636 KB |
Output is correct |
19 |
Correct |
290 ms |
16716 KB |
Output is correct |
20 |
Correct |
211 ms |
12960 KB |
Output is correct |
21 |
Correct |
322 ms |
17228 KB |
Output is correct |
22 |
Correct |
302 ms |
17228 KB |
Output is correct |