传送门

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

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

我们可以先把所有的边都取出来,然后按极角排序。枚举这个凸包的起点,然后做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. 2n皇后 - 回溯

    题目地址:http://www.51cpc.com/web/problem.php?id=1172 Summarize: 1. 递归回溯: 2. 先扫完一种皇后,再扫描另一种: 3. 循环输入: 4. ...

  2. Python判断字符串是否全是字母或数字

    str.isnumeric(): True if 只包含数字:otherwise False.注意:此函数只能用于unicode string str.isdigit(): True if 只包含数字 ...

  3. 【代码段】Android Studio使用DatePicker选择日期

    布局文件中放一个TextView就好了 Java文件如下: public class TestDatePickerActivity extends AppCompatActivity { privat ...

  4. vue-cli中src/main.js 的作用

    // The Vue build version to load with the `import` command // (runtime-only or standalone) has been ...

  5. fillder抓取APP数据之小程序

    1.下载fillder ,fillder官网:https://www.telerik.com/fiddler 2.安装好后设置fillder: 工具—>选项,打开设置面板.选择HTTPS选项卡. ...

  6. 438D - The Child and Sequence

    D. The Child and Sequence time limit per test 4 seconds memory limit per test 256 megabytes input st ...

  7. Mzc家中的男家丁

    题目背景 mzc与djn的…还没有众人皆知,所以我们要来宣传一下. 题目描述 mzc家很有钱(开玩笑),他家有n个男家丁,现在mzc要将她们全都聚集起来(干什么就不知道了).现在知道mzc与男家丁们互 ...

  8. 单例模式解决RabbitMQ超出最大连接问题

    今天在项目稳定性测试过程中遇到一个情景:通过工具jMeter一直请求消息转发服务器,消息转发服务器再向rabbitMQ发送数据,在这期间出现了问题.MQ意外宕机. 1. 查看rabbitMQ管理界面. ...

  9. Javascript网址跳转方法

    第一种: window.location.href="http://www.baidu.com"; 第二种: window.navigate("http://www.ba ...

  10. 创建NetCore2.2 Web项目+EFCore+SQLServer

    在空余时间学习下NetCore,记录日常,供参考. 1.确保已下载安装NetCore2.2SDK 环境,下载地址:https://dotnet.microsoft.com/download/dotne ...