Submission #1108152

# Submission time Handle Problem Language Result Execution time Memory
1108152 2024-11-03T03:41:34 Z Tsagana Star triangles (IZhO11_triangle) C++17
100 / 100
106 ms 21388 KB
#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define lnl long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second

using namespace std;

vector<pair<int, int>> vx;
vector<pair<int, int>> vy;
vector<pair<int, int>> p;
int X[300001];
int Y[300001];

void solve () {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int x, y; cin >> x >> y;
		vx.pb({x, i});
		vy.pb({y, i});
		p.pb({x, y});
	}
	sort(all(vx));
	sort(all(vy));

	int l = 0; p[vx[0].S].F = 0;
	for (int i = 1; i < n; i++) {
		if (vx[i].F != vx[i-1].F) l++;
		p[vx[i].S].F = l;
	}
	int r = 0; p[vy[0].S].S = 0;
	for (int i = 1; i < n; i++) {
		if (vy[i].F != vy[i-1].F) r++;
		p[vy[i].S].S = r;
	}

	for (auto i: p) {
		X[i.F]++; Y[i.S]++;
	}
	int ans = 0;
	for (auto i: p) {
		ans += (X[i.F]-1)*(Y[i.S]-1);
	}
	cout << ans;
}
signed main() {
	IOS 
	

	solve();
	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 2384 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 2936 KB Output is correct
8 Correct 1 ms 2512 KB Output is correct
9 Correct 2 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 4 ms 2896 KB Output is correct
13 Correct 4 ms 3140 KB Output is correct
14 Correct 5 ms 3176 KB Output is correct
15 Correct 41 ms 7088 KB Output is correct
16 Correct 42 ms 7600 KB Output is correct
17 Correct 38 ms 7088 KB Output is correct
18 Correct 39 ms 7096 KB Output is correct
19 Correct 103 ms 20828 KB Output is correct
20 Correct 78 ms 13212 KB Output is correct
21 Correct 106 ms 21380 KB Output is correct
22 Correct 106 ms 21388 KB Output is correct