제출 #1149646

#제출 시각아이디문제언어결과실행 시간메모리
1149646rahidilbayramli별들과 삼각형 (IZhO11_triangle)C++20
100 / 100
565 ms29160 KiB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define pb push_back
#define sz(v) (ll)(v.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.end()
#define f first
#define s second
#define pll pair<ll, ll>
#define pii pair<int, int>
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
void solve()
{
    ll n, i, j;
    cin >> n;
    map<ll, ll>mpx, mpy;
    vector<pll>vect;
    map<pll, ll>mp;
    for(i = 1; i <= n; i++)
    {
        ll x, y;
        cin >> x >> y;
        if(mp.find({x, y}) == mp.end())
            vect.pb({x, y}), mpx[x]++, mpy[y]++;
        mp[{x, y}]++;
    }
    ll res = 0;
    for(auto u : vect)
        res += mp[u] * ((mpx[u.f] - 1) * (mpy[u.s] - 1));
    cout << res << "\n";
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll tests = 1;
	//cin >> tests;
	while(tests--)
    {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...