求出凸包,显然四个点在凸包上。考虑枚举某点,再移动另一点作为对角线,容易发现剩下两点的最优位置是单调的。过程类似旋转卡壳。
#include#include #include #include #include #include using namespace std;#define ll long long#define N 2010#define vector point#define nxt(i) (i%tail+1)char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}int gcd(int n,int m){return m==0?n:gcd(m,n%m);}int read(){ int x=0,f=1;char c=getchar(); while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();} while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar(); return x*f;}int n;double ans;const double eps=1E-8;struct point{ double x,y; vector operator +(const vector&a) const { return (vector){x+a.x,y+a.y}; } vector operator -(const vector&a) const { return (vector){x-a.x,y-a.y}; } double operator *(const vector&a) const { return x*a.y-y*a.x; } bool operator <(const point&a) const { return x 1&&(b[tail]-b[tail-1])*(a[i]-b[tail-1]) =1;i--) { while (tail>1&&(b[tail]-b[tail-1])*(a[i]-b[tail-1])