제출 #1308499

#제출 시각아이디문제언어결과실행 시간메모리
1308499Mahog별들과 삼각형 (IZhO11_triangle)C++20
100 / 100
304 ms5936 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
const int MAX = 3e5 + 2;
pair<int, int> a[MAX];
int n;

void solve() {
    cin >> n;
    map<int, int> mp1, mp2;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].first >> a[i].second;
        mp1[a[i].first]++;
        mp2[a[i].second]++;
    }
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        res += 1LL * (mp1[a[i].first] - 1) * (mp2[a[i].second] - 1);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...