## 題解

n只有6，直接無腦dfs，注意判斷點在盒子外的情況

## Code

``````#include <stdio.h>
#include <string.h>
#include <math.h>
#define rep(i, a, b) for (int i = a; i <= b; i  )
#define fill(x, t) memset(x, t, sizeof(x))
#define db double
#define INF 0x3f3f3f3f
#define PI 3.141592653
#define N 7
using namespace std;
struct rec{int u, d, l, r;}r;
struct cir{int x, y; db r;}c[N];
int vis[N];
db ans = INF;
int x = 0, v = 1;
char ch = getchar();
while (ch < '0' || ch > '9'){
if (ch == '-'){
v = -1;
}
ch = getchar();
}
while (ch <= '9' && ch >= '0'){
x = x * 10   ch - '0';
ch = getchar();
}
return x * v;
}
inline db dist(cir a, cir b){
return sqrt((a.x - b.x) * (a.x - b.x)   (a.y - b.y) * (a.y - b.y));
}
inline db cal(db R){
return PI * R * R;
}
inline db max(db x, db y){
return x>y?x:y;
}
inline db min(db x, db y){
return x<y?x:y;
}
inline int dfs(int dep, db S, rec rc, int n){
if (dep == n   1){
ans = min(ans, S);
return 0;
}
rep(i, 1, n){
if (!vis[i]){
db R = INF;
rep(j, 1, n){
if (vis[j]){
R = min(R, dist(c[i], c[j]) - c[j].r);
}
}
R = min(R, c[i].y - rc.d);
R = min(R, rc.u - c[i].y);
R = min(R, c[i].x - rc.l);
R = min(R, rc.r - c[i].x);
if (R > 0){
vis[i] = true;
c[i].r = R;
dfs(dep   1, S - cal(R), rc, n);
c[i].r = 0;
vis[i] = false;
}else{
dfs(dep   1, S, rc, n);
}
}
}
}
int main(void){