제출 #974974

#제출 시각아이디문제언어결과실행 시간메모리
974974vjudge1별들과 삼각형 (IZhO11_triangle)C++17
100 / 100
940 ms34548 KiB
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i = 1; i<=n; i++)
#define fi first
#define sc second
using namespace std;



int main(){
	map<ll,ll> mpx,mpy;
	map<pair<ll,ll>, ll> mpdup;
	ll n;
	cin >> n;
	pair<ll,ll> arr[n+99];
	forn(i,n){
		ll x,y;
		cin >> x >> y;
		mpx[x]++;
		mpy[y]++;
		mpdup[{x,y}]++;
		arr[i] = {x,y};
	}
	ll sum = 0;

	
	forn(i,n){
		ll x = arr[i].fi,y = arr[i].sc;
		
		if(mpdup[{x,y}] == 0)continue;
		
		ll dup = mpdup[{x,y}];
		
		if(mpdup[{x,y}] == 1){
			sum += (mpx[x]-1) * (mpy[y]-1); 	
		}else{
			sum += (mpx[x] - dup )*(mpy[y] - dup )*(dup);
		}
		mpdup[{x,y}] = 0;
	}
	
	cout<<sum;
}
#Verdict Execution timeMemoryGrader output
Fetching results...