Submission #960636

# Submission time Handle Problem Language Result Execution time Memory
960636 2024-04-10T18:13:10 Z starchan Star triangles (IZhO11_triangle) C++17
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int MX = 3e5+5;
int cnt[MX][2];
signed main()
{
	fast();
	int n;
	cin >> n;
	array<int, 2> pt[n];
	for(int i = 0; i < n; i++)
		cin >> pt[i][0] >> pt[i][1];
	vector<int> V;
	for(int i = 0; i < n; i++)
		V.pb(pt[i][0]);
	sort(V.begin(), V.end());
	vector<int> M; M.pb(V[0]);
	for(int k: V)
	{
		if(k != M.back())
			M.pb(k);
	}
	for(int i = 0; i < n; i++)
	{
		pt[i][0] = lower_bound(M.begin(), M.end(), pt[i][0])-M.begin();
		cnt[pt[i][0]][0]++;
	}
	V.clear();
	M.clear();
	for(int i = 0; i < n; i++)
		V.pb(pt[i][0]);
	sort(V.begin(), V.end());
	M.pb(V[0]);
	for(int k: V)
	{
		if(k != M.back())
			M.pb(k);
	}
	for(int i = 0; i < n; i++)
	{
		pt[i][1] = lower_bound(M.begin(), M.end(), pt[i][1])-M.begin();
		cnt[pt[i][1]][1]++;
	}
	int ans = 0;
	for(int i = 0; i < n; i++)
		ans+=((cnt[pt[i][0]][0]-1)*(cnt[pt[i][1]][1]-1));
	cout << ans << "\n";
	return 0;
}	
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -