#include "bits/stdc++.h"
using namespace std;
int countRightTriangles(vector<pair<int, int>>& stars) {
unordered_map<int, int> xFreq, yFreq;
for (const auto& star : stars) {
xFreq[star.first]++;
yFreq[star.second]++;
}
int count = 0;
for (const auto& star : stars) {
count += (xFreq[star.first] - 1) * (yFreq[star.second] - 1);
}
return count;
}
int main() {
int N;
cin >> N;
vector<pair<int, int>> stars;
for (int i = 0; i < N; ++i) {
int x, y;
cin >> x >> y;
stars.emplace_back(x, y);
}
int result = countRightTriangles(stars);
cout << result << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
6 ms |
824 KB |
Output is correct |
13 |
Correct |
7 ms |
1368 KB |
Output is correct |
14 |
Correct |
8 ms |
1372 KB |
Output is correct |
15 |
Correct |
71 ms |
5884 KB |
Output is correct |
16 |
Correct |
75 ms |
6084 KB |
Output is correct |
17 |
Correct |
70 ms |
5828 KB |
Output is correct |
18 |
Correct |
69 ms |
5876 KB |
Output is correct |
19 |
Correct |
184 ms |
12220 KB |
Output is correct |
20 |
Correct |
133 ms |
8900 KB |
Output is correct |
21 |
Correct |
194 ms |
13412 KB |
Output is correct |
22 |
Correct |
201 ms |
12412 KB |
Output is correct |