Submission #891142

#TimeUsernameProblemLanguageResultExecution timeMemory
891142JAVA_FFStar triangles (IZhO11_triangle)C++14
100 / 100
201 ms13412 KiB
#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 timeMemoryGrader output
Fetching results...