传送门:CF682E
题解
找到图中面积最大的三角形,分别将三条边作为平行四边形对角线向外翻折三角形,如下图:
图片来源:cdsszjj的题解
稍微讨论一下就会发现凸包一定被这个三角形覆盖。
虽然提示了大三角形面积 ≤ 4 S \leq 4S ≤4S,但想都想不到啊qwq!
于是 O ( n 2 ) O(n^2) O(n2)旋转卡壳/迭代求最大三角形即可。
代码
代码也是贴的学长的(大雾
旋转卡壳:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=5005;
struct point
{
int x,y;
point(){
}
point(int _x,int _y):x(_x),y(_y){
}
inline friend point operator - (const point &a,const point &b)
{
return point(a.x-b.x,a.y-b.y);}
inline friend point operator + (const point &a,const point &b)
{
return point(a.x+b.x,a.y+b.y);}
inline friend ll operator * (const point &a,const point &b)
{
return 1ll*a.x*b.y-1ll*a.y*b.x;}
inline ll dis(){
return 1ll*x*x+1ll*