#include<bits/stdc++.h>
#define PI 3.1415926
using namespace std;
double n;
double xl, yl, xr, yr;
pair<double, double> a[7];
double h[7];
double h2[7];
double h3[7];
stack<int> d;
double res;
double s = 0x3f3f3f;
bool st[7];
double ss;
void bfs(int u) {
if (u == n) {
s = min(ss, s);
return;
}
for (int i = 1; i <= n; i++) {
cout << u << endl;
if (u == 0) {
for (int j = 1; j <= n; j++) {
h[j] = h3[j];
}
for (int j = 1; j <= n; j++) {
h2[j] = h3[j];
}
}
if (!st[i]) {
cout << i << endl;
d.push(i);
int hh = h[i];
ss -= h[i] * h[i] * PI;
st[i] = true;
for (int j = 1; j <= n; j++) {
h2[j] = h[j];
}
for (int j = 1; j <= n; j++) {
if (!st[j])
h[j] = min(h[j], max(sqrt(pow((a[j].first - a[i].first), 2) + pow((a[j].second - a[i].second), 2)) - h[i], 0.0));
}
for (int j = 1; j <= n; j++) {
cout << h[j] << " ";
}
puts("");
for (int j = 1; j <= n; j++) {
cout << h2[j] << " ";
}
puts("");
for (int j = 1; j <= n; j++) {
cout << h3[j] << " ";
}
puts("");
bfs(u + 1);
d.pop();
for (int j = 1; j <= n; j++) {
h[j] = h2[j];
}
st[i ] = false;
ss += h[i] * h[i] * PI;
}
}
}
int main() {
cin >> n;
cin >> xl >> yl >> xr >> yr;
ss = abs(xr - xl) * abs(yr - yl);
for (int i = 1; i <= n; i++) {
double x, y;
cin >> x >> y;
a[i] = { x,y };
h[i] = min({ abs(x - xl), abs(x - xr), abs(y - yl), abs(y - yr) });
}
for (int j = 1; j <= n; j++) {
h3[j] = h[j];
}
bfs(0);
printf("%.0lf", s);
return 0;
}
第八个点改了精度也过不去,疑似部分步骤有错?
求大佬邦邦