#include <bits/stdc++.h>
typedef long long ll;
struct P {
ll x, y;
void read(std::map <ll, ll>& mx, std::map <ll, ll>& my) {
std::cin >> x >> y;
bool existX = mx.find(x) == mx.end(), existY = my.find(y) == my.end();
mx[x]++, my[y]++;
mx[x] -= existX, my[y] -= existY;
}
};
int main() {
std::ios::sync_with_stdio(0); std::cin.tie(0);
int n; std::cin >> n;
ll ans = 0;
std::map <ll, ll> mx, my;
std::vector <P> a(n);
for (auto& p : a) p.read(mx, my);
while (n--) ans += mx[a[n].x] * my[a[n].y];
std::cout << ans << "\n";
//std::cout.flush(); std::cin >> n;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
10 ms |
1260 KB |
Output is correct |
13 |
Correct |
10 ms |
1388 KB |
Output is correct |
14 |
Correct |
15 ms |
1772 KB |
Output is correct |
15 |
Correct |
190 ms |
7908 KB |
Output is correct |
16 |
Correct |
197 ms |
8292 KB |
Output is correct |
17 |
Correct |
175 ms |
7908 KB |
Output is correct |
18 |
Correct |
178 ms |
8060 KB |
Output is correct |
19 |
Correct |
486 ms |
11108 KB |
Output is correct |
20 |
Correct |
356 ms |
9956 KB |
Output is correct |
21 |
Correct |
541 ms |
11620 KB |
Output is correct |
22 |
Correct |
526 ms |
11492 KB |
Output is correct |