Submission #1108510

# Submission time Handle Problem Language Result Execution time Memory
1108510 2024-11-04T10:09:21 Z Nomio Star triangles (IZhO11_triangle) C++17
100 / 100
228 ms 14408 KB
#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 time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2552 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 2 ms 2572 KB Output is correct
12 Correct 9 ms 3524 KB Output is correct
13 Correct 6 ms 3664 KB Output is correct
14 Correct 10 ms 4224 KB Output is correct
15 Correct 82 ms 8520 KB Output is correct
16 Correct 87 ms 8836 KB Output is correct
17 Correct 82 ms 8544 KB Output is correct
18 Correct 84 ms 8604 KB Output is correct
19 Correct 220 ms 13640 KB Output is correct
20 Correct 148 ms 11424 KB Output is correct
21 Correct 228 ms 14408 KB Output is correct
22 Correct 221 ms 14288 KB Output is correct