Submission #1296908

#TimeUsernameProblemLanguageResultExecution timeMemory
1296908chithanhnguyenStar triangles (IZhO11_triangle)C++20
100 / 100
877 ms28020 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ld long double
#define pii pair<int, int>
#define fi first
#define se second
#define __builtin_popcount __builtin_popcountll
#define all(x) (x).begin(), (x).end()

#define debug(a, l, r) for (int i = (l); i <= (r); ++i) cout << (a)[i] << ' '; cout << '\n';

const int MAXN = 3e5 + 5;
int n, x[MAXN], y[MAXN];
map<int, int> cntx, cnty;
map<pii, int> cnt;

signed main() {
    #ifdef NCTHANH
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x[i] >> y[i];
        cntx[x[i]]++;
        cnty[y[i]]++;
        cnt[{x[i], y[i]}]++;
    }

    int res = 0;
    for (int i = 1; i <= n; ++i) {
        int cx = cntx[x[i]] - cnt[{x[i], y[i]}];
        int cy = cnty[y[i]] - cnt[{x[i], y[i]}];
        res += cx * cy;
    }

    cout << res;

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