Submission #379588

# Submission time Handle Problem Language Result Execution time Memory
379588 2021-03-18T17:33:47 Z penguinhacker Star triangles (IZhO11_triangle) C++14
100 / 100
208 ms 10712 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

int n, x[300000], y[300000], cx[300000], cy[300000];
void compress(int a[]) {
	vector<int> d(a, a + n);
	sort(d.begin(), d.end());
	d.resize(unique(d.begin(), d.end()) - d.begin());
	for (int i = 0; i < n; ++i)
		a[i] = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> x[i] >> y[i];
	compress(x);
	compress(y);
	for (int i = 0; i < n; ++i)
		++cx[x[i]], ++cy[y[i]];
	ll ans = 0;
	for (int i = 0; i < n; ++i)
		ans += (ll)(cx[x[i]] - 1) * (cy[y[i]] - 1);
	cout << ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 5 ms 620 KB Output is correct
13 Correct 5 ms 748 KB Output is correct
14 Correct 7 ms 748 KB Output is correct
15 Correct 65 ms 3940 KB Output is correct
16 Correct 72 ms 4416 KB Output is correct
17 Correct 66 ms 3876 KB Output is correct
18 Correct 65 ms 3940 KB Output is correct
19 Correct 186 ms 10040 KB Output is correct
20 Correct 133 ms 7260 KB Output is correct
21 Correct 202 ms 10584 KB Output is correct
22 Correct 208 ms 10712 KB Output is correct