Submission #877826

#TimeUsernameProblemLanguageResultExecution timeMemory
877826__Davit__Star triangles (IZhO11_triangle)C++17
100 / 100
249 ms12176 KiB
#include<bits/stdc++.h>

#define ll long long
#define lld long double
#define ff first
#define ss second
#define pb push_back
#define vr(v) v.begin(),v.end()
#define rv(v) v.rbegin(),v.rend()
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Davit cout.tie(NULL);
#define FOR(i, n) for(int i = 0;i<n;i++)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

//typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
//        tree_order_statistics_node_update> indexed_set;


//#include "algo/debug.h"


int main() {
    Code
    By
    Davit
    int n;
    cin >> n;
    map<int, int> X, Y;
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].ff >> v[i].ss;
        X[v[i].ff]++;
        Y[v[i].ss]++;
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        int x = v[i].ff, y = v[i].ss;
        ans += 1ll * (X[x] - 1) * (Y[y] - 1);
    }
    cout << ans << endl;
}

#Verdict Execution timeMemoryGrader output
Fetching results...