本地跑洛谷数据跑过了但交上去却只对一个点是为什么,求助大佬
查看原帖
本地跑洛谷数据跑过了但交上去却只对一个点是为什么,求助大佬
905823
Peanut_qwq楼主2023/8/8 15:40
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
const double pi = acos(-1.0);//pi的高精度值 
struct Node{
	double x, y;
}a[10];
int n;
bool st[10];
double r[10];
double x1, y11, x2, y22;
double ans;

double getr(int p, int q){
	double x = fabs(a[p].x - a[q].x);
	double y = fabs(a[p].y - a[q].y);
	double rr = (double)sqrt(x * x + y * y);
	rr = rr - r[q];
}

void dfs(double sum, int u){
	if(u == n){
		ans = max(ans, sum);
	}
	for(int i = 1; i <= n; i ++ ){
		if(!st[i]){
			double xx = min(fabs(a[i].x - x1), fabs(a[i].x - x2));
			double yy = min(fabs(a[i].y - y11), fabs(a[i].y - y22));
			r[i] = min(xx, yy);
			for(int j = 1; j <= n; j ++ ){
				if(st[j]){
					r[i] = min(r[i], getr(i, j));			
				}
			}
			st[i] = true;
			if(r[i] < 0)dfs(sum, u + 1); 
			else dfs(sum + (double)pi * r[i] * r[i], u + 1);
			st[i] = false;
		}
	}
}


int main(){
	
	cin >> n;
	
	cin >> x1 >> y11 >> x2 >> y22;
	for(int i = 1; i <= n; i ++ ){
		double x, y;
		cin >> x >> y;
		a[i] = {x, y};
	}
	dfs(0, 0);
	double summ = (double)fabs(x1 - x2) * (double)fabs(y11 - y22);
	summ = summ - ans;
	printf("%d", (int)(summ + 0.5));
	return 0;
}
2023/8/8 15:40
加载中...