传送门

反正我是看不出来这题和凸包有什么关系……大佬们是怎么想到的……

不准确一点的说,本题就是要我们求一个边上点数最多的凸包

我们可以先把所有的边都取出来,然后按极角排序。枚举这个凸包的起点,然后做dp即可

复杂度\(O(n^3)\)

//minamoto
#include<bits/stdc++.h>
#define rint register int
using namespace std;
const int N=305;
struct node{int u,v;double x,y;}p[N],e[N*N];int f[N];
inline bool cmp(node a,node b){return atan2(a.x,a.y)<atan2(b.x,b.y);}
int main(){
// freopen("testdata.in","r",stdin);
int n,tot=0,ans=0;scanf("%d",&n);
for(rint i=1;i<=n;++i)scanf("%lf%lf",&p[i].x,&p[i].y);
for(rint i=1;i<=n;++i)for(rint j=1;j<=n;++j)if(i!=j){
e[++tot]={i,j,p[j].x-p[i].x,p[j].y-p[i].y};
}sort(e+1,e+1+tot,cmp);
for(rint i=1;i<=n;++i){
memset(f,0xef,sizeof(f));f[i]=0;
for(rint j=1;j<=tot;++j)
f[e[j].v]=max(f[e[j].v],f[e[j].u]+1);
ans=max(ans,f[i]);
}printf("%d\n",ans);return 0;
}

P2924 [USACO08DEC]大栅栏Largest Fence的更多相关文章

  1. BZOJ1591 & 洛谷2924:[USACO2008 DEC]Largest Fence 最大的围栏——题解

    http://www.lydsy.com/JudgeOnline/problem.php?id=1591 https://www.luogu.org/problemnew/show/P2924#sub ...

  2. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  3. Java 特定规则排序-LeetCode 179 Largest Number

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  4. [LeetCode] Split Array Largest Sum 分割数组的最大值

    Given an array which consists of non-negative integers and an integer m, you can split the array int ...

  5. [LeetCode] Largest Divisible Subset 最大可整除的子集合

    Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of ...

  6. [LeetCode] Largest BST Subtree 最大的二分搜索子树

    Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest mea ...

  7. [LeetCode] Paint Fence 粉刷篱笆

    There is a fence with n posts, each post can be painted with one of the k colors. You have to paint ...

  8. [LeetCode] Kth Largest Element in an Array 数组中第k大的数字

    Find the kth largest element in an unsorted array. Note that it is the kth largest element in the so ...

  9. [LeetCode] Largest Number 最大组合数

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

随机推荐

  1. 40条常见的移动端Web页面问题解决方案

    1.安卓浏览器看背景图片,有些设备会模糊.想让图片在手机里显示更为清晰,必须使用2x的背景图来代替img标签(一般情况都是用2倍).例如一个div的宽高是100100,背景图必须得200200,然后b ...

  2. enote笔记语言(2)(ver0.4)

    why not(whyn't)                    为什么不(与“why”相反对应,是它的反面)   how对策 how设计   key-memo:                 ...

  3. Luogu P4503 [CTSC2014]企鹅QQ

    思路 如果直接暴力的比较的话,不用想也知道会超时 所以考虑另一种方法,将前缀和的思想运用到hash中.用两个hash,一个从前往后记录,一个从后往前记录,然后枚举哪一位是不相同的,然后删掉这一位,将这 ...

  4. Linux之sed:删除某行以及替换

    sed是一个很好的文件处理工具,本身是一个管道命令,主要是以行为单位进行处理,可以将数据行进行替换.删除.新增.选取等特定工作,下面先了解一下sed的用法sed命令行格式为:         sed ...

  5. 谈谈TCP中的TIME_WAIT

    所以,本文也来凑个热闹,来谈谈TIME_WAIT. 为什么要有TIME_WAIT? TIME_WAIT是TCP主动关闭连接一方的一个状态,TCP断开连接的时序图如下: 当主动断开连接的一方(Initi ...

  6. 在vue项目中快速使用element UI

    推荐使用npm安装 1.安装:npm install element-ui -S 2.整体引入: 在你项目的main.js中写入: import ElementUI from 'element-ui' ...

  7. 在此计算机中仅有部分visual studio2010产品已升级到SP1,只有全部升级,产品才能正常运行

    先说废话: 本人机子刚装系统Win10 专业版 1709 开始安装vs2010的时候中途报错了,有一个什么驱动不兼容,被我给关闭了,继续安装完,然后找不到vs的启动快捷方式,开始里面没有,于是我开始修 ...

  8. 重载与重写的区别----https://blog.csdn.net/zhu_apollo/article/details/1852542

    重载 overloading        1) 方法重载是让类以统一的方式处理不同类型数据的一种手段.多个同名函数同时存在,具有不同的参数个数/类型.重载是一个类中多态性的一种表现.        ...

  9. VNC Viewer 设置屏幕分辨率-解决屏幕分辨率问题

    https://blog.csdn.net/runningtortoises/article/details/51425332

  10. - > 动规讲解基础讲解四——最大子段和问题

    给出一个整数数组a(正负数都有),如何找出一个连续子数组(可以一个都不取,那么结果为0),使得其中的和最大?   例如:-2,11,-4,13,-5,-2,和最大的子段为:11,-4,13.和为20. ...