제출 #765530

#제출 시각아이디문제언어결과실행 시간메모리
765530nguyen31hoang08minh2003Star triangles (IZhO11_triangle)C++17
100 / 100
240 ms12216 KiB
#include <bits/stdc++.h>
using namespace std;

template<class X, class Y>
bool minimize(X &x, const Y &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template<class X, class Y>
bool maximize(X &x, const Y &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

constexpr int MAX_N = 300005;

int N, X[MAX_N], Y[MAX_N];
map<int, int> x, y;
long long result;

signed main() {
    #ifdef LOCAL
        freopen("input.INP", "r", stdin);
//        freopen("log.TXT", "w", stderr);
//        freopen("output.out", "w", stdout);
    #endif
    cin.tie(0) -> sync_with_stdio(0);
    cout.tie(0);

    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> X[i] >> Y[i];
        ++x[X[i]];
        ++y[Y[i]];
    }

    for (int i = 1; i <= N; ++i)
        result += (x[X[i]] - 1LL) * (y[Y[i]] - 1LL);

    cout << result << '\n';

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...