【Codeforces】682E. Alyona and Triangles-旋转卡壳/迭代

传送门: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*
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值