제출 #1108510

#제출 시각아이디문제언어결과실행 시간메모리
1108510NomioStar triangles (IZhO11_triangle)C++17
100 / 100
228 ms14408 KiB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

const int maxn = 6e5;

int a[maxn + 1] {}, b[maxn + 1] {};

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	set<int> S;
	int x[n], y[n];
	for(int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		S.insert(x[i]);
		S.insert(y[i]);
	}
	int c = 0;
	map<int, int> m;
	for(int X : S) {
		m[X] = c;
		c++;
	}
	for(int i = 0; i < n; i++) {
		x[i] = m[x[i]];
		y[i] = m[y[i]];
	}
	for(int i = 0; i < n; i++) {
		a[x[i]]++;
		b[y[i]]++;
	}
	ll cnt = 0;
	for(int i = 0; i < n; i++) {
		cnt += 1LL * (a[x[i]] - 1) * (b[y[i]] - 1);
	}
	cout << cnt << '\n';
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...