#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = (int)3e5 + 7;
int n;
map < int, int > mpx, mpy;
map < pair < int, int >, int > mp;
int x[N], y[N];
main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> x[i] >> y[i];
mpx[x[i]]++;
mpy[y[i]]++;
mp[{x[i], y[i]}]++;
}
ll ans = 0;
for (int i = 1; i <= n; i++) {
ll res1, res2;
res1 = mpx[x[i]];
res2 = mpy[y[i]];
res1 -= mp[{x[i], y[i]}];
res2 -= mp[{x[i], y[i]}];
ans += res1 * res2;
}
cout << ans;
}
Compilation message
triangle.cpp:14:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
2 ms |
508 KB |
Output is correct |
4 |
Correct |
2 ms |
508 KB |
Output is correct |
5 |
Correct |
2 ms |
508 KB |
Output is correct |
6 |
Correct |
2 ms |
508 KB |
Output is correct |
7 |
Correct |
2 ms |
508 KB |
Output is correct |
8 |
Correct |
2 ms |
644 KB |
Output is correct |
9 |
Correct |
3 ms |
644 KB |
Output is correct |
10 |
Correct |
3 ms |
644 KB |
Output is correct |
11 |
Correct |
3 ms |
676 KB |
Output is correct |
12 |
Correct |
17 ms |
1820 KB |
Output is correct |
13 |
Correct |
15 ms |
1820 KB |
Output is correct |
14 |
Correct |
22 ms |
2144 KB |
Output is correct |
15 |
Correct |
380 ms |
10720 KB |
Output is correct |
16 |
Correct |
433 ms |
11372 KB |
Output is correct |
17 |
Correct |
396 ms |
11372 KB |
Output is correct |
18 |
Correct |
414 ms |
11372 KB |
Output is correct |
19 |
Correct |
1438 ms |
23328 KB |
Output is correct |
20 |
Correct |
973 ms |
23328 KB |
Output is correct |
21 |
Correct |
1485 ms |
24908 KB |
Output is correct |
22 |
Correct |
1497 ms |
24948 KB |
Output is correct |