이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
struct Vec {
	ll x, y, c, i;
	Vec operator-(Vec a) {
		return {x-a.x, y-a.y};
	}
	ll operator*(Vec a) {
		return x*a.y - y*a.x;
	}
};
int N;
ll Lcnt[5000050][3], Rcnt[5000050][3];
Vec A[3030];
vector<Vec> pt[3];
vector<pii> v;
void solve(int t) {
	sort(pt[t].begin(), pt[t].end(), [&](Vec a, Vec b) {
		if (a.x != b.x) return a.x < b.x;
		return a.y < b.y;
	});
	int idx[3030]; memset(idx, 0, sizeof idx);
	for (int i=0; i<pt[t].size(); i++) {
		idx[pt[t][i].i] = i;
	}
	for (int i=0; i<v.size(); i++) {
		int a = v[i].va, b = v[i].vb;
		Vec d = A[b] - A[a];
		int lo = 0, hi = pt[t].size();
		while (lo<hi) {
			int mid = lo+hi+1>>1;
			Vec x = pt[t][mid-1] - A[a];
			if (d*x < 0) lo = mid;
			else hi = mid-1;
		}
		Lcnt[i][t] = lo;
		lo = 0, hi = pt[t].size();
		while (lo<hi) {
			int mid = lo+hi>>1;
			Vec x = pt[t][mid] - A[a];
			if (d*x > 0) hi = mid;
			else lo = mid+1;
		}
		Rcnt[i][t] = pt[t].size() - lo;
		if (A[a].c != t || A[b].c != t) continue;
		swap(pt[t][idx[A[a].i]], pt[t][idx[A[b].i]]);
		swap(idx[A[a].i], idx[A[b].i]);
	}
}
int main() {
	cin.tie(0); ios_base::sync_with_stdio(0);
	cin >> N;
	for (int i=0; i<N; i++) {
		cin >> A[i].x >> A[i].y >> A[i].c; A[i].i = i;
		pt[A[i].c].push_back(A[i]);
	}
	for (int i=0; i<N; i++) {
		for (int j=0; j<N; j++) {
			if (i == j) continue;
			if (A[i].x < A[j].x) v.push_back({i, j});
			if (A[i].x == A[j].x && A[i].y < A[j].y) v.push_back({i, j});
		}
	}
	sort(v.begin(), v.end(), [&](pii a, pii b) {
		Vec p = A[a.vb] - A[a.va];
		Vec q = A[b.vb] - A[b.va];
		ll t = p*q;
		return t>0;
	});
	for (int i=0; i<3; i++) solve(i);
	ll ans = 0;
	for (int i=0; i<v.size(); i++) {
		int p = A[v[i].va].c, q = A[v[i].vb].c;
		ll lp=1, rp=1, lq=1, rq=1;
		for (int j=0; j<3; j++) {
			if (j != p) lp *= Lcnt[i][j], rp *= Rcnt[i][j];
			if (j != q) lq *= Lcnt[i][j], rq *= Rcnt[i][j];
		}
		ans += lp*rq + rp*lq;
	}
	cout << ans/2;
}
컴파일 시 표준 에러 (stderr) 메시지
constellation2.cpp: In function 'void solve(int)':
constellation2.cpp:32:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<pt[t].size(); i++) {
                ~^~~~~~~~~~~~~
constellation2.cpp:35:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<v.size(); i++) {
                ~^~~~~~~~~
constellation2.cpp:41:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    int mid = lo+hi+1>>1;
              ~~~~~^~
constellation2.cpp:51:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    int mid = lo+hi>>1;
              ~~^~~
constellation2.cpp: In function 'int main()':
constellation2.cpp:90:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<v.size(); i++) {
                ~^~~~~~~~~| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |