답안 #960638

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
960638 2024-04-10T18:14:19 Z starchan 별들과 삼각형 (IZhO11_triangle) C++17
100 / 100
150 ms 17612 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][1]);
	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;
}	
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 4 ms 1116 KB Output is correct
13 Correct 4 ms 1116 KB Output is correct
14 Correct 5 ms 1116 KB Output is correct
15 Correct 49 ms 7516 KB Output is correct
16 Correct 57 ms 8156 KB Output is correct
17 Correct 48 ms 7676 KB Output is correct
18 Correct 49 ms 7588 KB Output is correct
19 Correct 139 ms 17308 KB Output is correct
20 Correct 98 ms 12016 KB Output is correct
21 Correct 150 ms 17612 KB Output is correct
22 Correct 150 ms 17348 KB Output is correct