제출 #902324

#제출 시각아이디문제언어결과실행 시간메모리
902324dsyz별들과 삼각형 (IZhO11_triangle)C++17
100 / 100
826 ms19780 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);
	ll N;
	cin>>N;
	pair<ll,ll> arr[N];
	map<ll,ll> rowcnt, colcnt, row, col;
	for(ll i = 0;i < N;i++){
		cin>>arr[i].first>>arr[i].second;
		rowcnt[arr[i].first]++;
		colcnt[arr[i].second]++;
	}
	for(ll i = 0;i < N;i++){
		row[arr[i].first] += (colcnt[arr[i].second] - 1);
		col[arr[i].second] += (rowcnt[arr[i].first] - 1);
	}
	ll sum = 0;
	for(ll i = 0;i < N;i++){
		sum += (row[arr[i].first] - (colcnt[arr[i].second] - 1));
		sum += (col[arr[i].second] - (rowcnt[arr[i].first] - 1));
	}
	cout<<sum / 2<<'\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...