C11TRCNT - Bắn máy bay

Tác giả: happyboy99x

Ngôn ngữ: C++

#include<cstdio>
#include<climits>

#define N 200
long long x[N], y[N];
int safe[N], strongValue, n;

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) scanf("%lld%lld", x+i, y+i);
	for(int i = 0; i < n; ++i)
		for(int j = i+1; j < n; ++j)
			for(int k = j+1; k < n; ++k)
				if((x[j]-x[i])*(y[k]-y[j]) != (x[k]-x[j])*(y[j]-y[i])) {
					++strongValue; ++safe[i]; ++safe[j]; ++safe[k];
				}
	int min = INT_MAX, pos;
	for(int i = 0; i < n; ++i)
		if(safe[i] < min) {
			min = safe[i];
			pos = i;
		}
	printf("%d %d\n", strongValue, pos+1);
	return 0;
}

Download