#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <cmath>
#include <vector>
#include <iomanip>
#include <random>
#include <chrono>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pb push_back
#define US freopen("milkvisits.in", "r", stdin); freopen("milkvisits.out", "w", stdout);
ll gcd(ll a, ll b)
{
if (a == 0 || b == 0) {
return max(a, b);
}
if (a <= b) {
return gcd(a, b % a);
}
else {
return gcd(a % b, b);
}
}
ll lcm(ll a, ll b) {
return (a / gcd(a, b)) * b;
}
const int N = 300005;
const ll oo = 1000000000000000, MOD = 998244353;
pair<ll, ll> p[N];
void solve() {
int n;
cin >> n;
map<ll, ll> mp, kp;
for (int i = 1; i <= n; ++i) {
cin >> p[i].fr >> p[i].sc;
mp[p[i].sc]++;
kp[p[i].fr]++;
}
sort(p + 1, p + n + 1);
ll ans = 0;
for (int i = 1; i <= n; ++i) {
ans += (mp[p[i].sc]-1)*(kp[p[i].fr]-1);
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//US
int tt = 1;
//cin >> tt;
while (tt--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
1172 KB |
Output is correct |
13 |
Correct |
5 ms |
1372 KB |
Output is correct |
14 |
Correct |
9 ms |
1872 KB |
Output is correct |
15 |
Correct |
89 ms |
8536 KB |
Output is correct |
16 |
Correct |
87 ms |
8784 KB |
Output is correct |
17 |
Correct |
80 ms |
8624 KB |
Output is correct |
18 |
Correct |
80 ms |
8536 KB |
Output is correct |
19 |
Correct |
214 ms |
14672 KB |
Output is correct |
20 |
Correct |
156 ms |
12948 KB |
Output is correct |
21 |
Correct |
233 ms |
15520 KB |
Output is correct |
22 |
Correct |
231 ms |
15444 KB |
Output is correct |