# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
891142 | JAVA_FF | Star triangles (IZhO11_triangle) | C++14 | 201 ms | 13412 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |