#include <bits/stdc++.h>
#define bismillah ios_base::sync_with_stdio(0); cin.tie(0);
#define int long long
#define v vector
#define pb push_back
#define ppb pop_back
#define all(x) x.begin(), x.end()
#define rall(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
#define fi first
#define se second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define tc int t = 1; while (t--)
// #define tc int t; cin >> t; while (t--)
const int MOD = 1e9 + 7;
const int INF = 1e17;
using namespace std;
signed main(){
bismillah;
tc {
//input
int n; cin >> n;
map<int, int> mpx, mpy;
int coordX[n + 1], coordY[n + 1];
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
mpx[x]++; mpy[y]++;
coordX[i] = x;
coordY[i] = y;
}
//solve
int ans = 0;
for (int i = 0; i < n; i++) {
ans += (mpx[coordX[i]] - 1) * (mpy[coordY[i]] - 1);
}
//output
cout << ans << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
348 KB |
Output is correct |
7 |
Correct |
1 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 |
1116 KB |
Output is correct |
13 |
Correct |
5 ms |
1116 KB |
Output is correct |
14 |
Correct |
8 ms |
1688 KB |
Output is correct |
15 |
Correct |
90 ms |
5900 KB |
Output is correct |
16 |
Correct |
104 ms |
6224 KB |
Output is correct |
17 |
Correct |
85 ms |
5716 KB |
Output is correct |
18 |
Correct |
85 ms |
5712 KB |
Output is correct |
19 |
Correct |
230 ms |
8784 KB |
Output is correct |
20 |
Correct |
165 ms |
7656 KB |
Output is correct |
21 |
Correct |
247 ms |
9040 KB |
Output is correct |
22 |
Correct |
273 ms |
9232 KB |
Output is correct |