| 比赛 | 
    csp2025模拟练习2 | 
    评测结果 | 
    AAAAAAAAAAAAAAAAATTT | 
    | 题目名称 | 
    愤怒的小鸟 | 
    最终得分 | 
    85 | 
    | 用户昵称 | 
    梦那边的美好TE | 
    运行时间 | 
    10.652 s  | 
    | 代码语言 | 
    C++ | 
    内存使用 | 
    5.79 MiB  | 
    | 提交时间 | 
    2025-10-29 10:19:11 | 
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const double eps=1e-8;
const int N=(1<<18);
int T,n,o,dp[N],mk[N];
double X[20],Y[20],x[20],y[20];
bool chk[20][20];
double fabs(double v){
	return v<0?-v:v;
}
bool check(int s){
	int cnt=0;
	for(int i=0;i<n;i++){
		if((s>>i)&1){
			++cnt;
			x[cnt]=X[i];
			y[cnt]=Y[i];
		}
	}
	if(cnt<=1)return 1;
	if(fabs(x[1]-x[2])<eps)return 0;
	double w=(x[1]*x[1])/(x[1]*x[1]+x[2]*x[2]);
	double b=(y[1]-w*y[1]-w*y[2])/(x[1]-w*x[1]-w*x[2]);
	double a=(y[1]-b*x[1])/(x[1]*x[1]);
	if(a>0)return 0;
	if(fabs(a)<eps)return 0;
	for(int i=1;i<=cnt;i++){
		if(fabs(y[i]-a*x[i]*x[i]-b*x[i])>eps)return 0;
	}
	return 1;
}
void work(){
	scanf("%d %d",&n,&o);
	for(int i=0;i<n;i++)scanf("%lf %lf",X+i,Y+i);
	memset(dp,0x3f,sizeof(dp));dp[0]=0;
	memset(mk,0,sizeof(mk));
	for(int i=0;i<(1<<n);i++)mk[i]=check(i);
	for(int i=1;i<(1<<n);i++){
		for(int j=i;j;j=(j-1)&i){
			if(mk[j])dp[i]=min(dp[i],dp[i^j]+1);
		}
	}
	printf("%d\n",dp[(1<<n)-1]);
	return;
}
int main(){
	freopen("angrybirds.in","r",stdin);
	freopen("angrybirds.out","w",stdout);
	scanf("%d",&T);
	while(T--)work();
	return 0;
}