P2924 [USACO08DEC]大栅栏Largest Fence
反正我是看不出来这题和凸包有什么关系……大佬们是怎么想到的……
不准确一点的说,本题就是要我们求一个边上点数最多的凸包
我们可以先把所有的边都取出来,然后按极角排序。枚举这个凸包的起点,然后做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的更多相关文章
- BZOJ1591 & 洛谷2924:[USACO2008 DEC]Largest Fence 最大的围栏——题解
http://www.lydsy.com/JudgeOnline/problem.php?id=1591 https://www.luogu.org/problemnew/show/P2924#sub ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- Java 特定规则排序-LeetCode 179 Largest Number
Given a list of non negative integers, arrange them such that they form the largest number. For exam ...
- [LeetCode] Split Array Largest Sum 分割数组的最大值
Given an array which consists of non-negative integers and an integer m, you can split the array int ...
- [LeetCode] Largest Divisible Subset 最大可整除的子集合
Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of ...
- [LeetCode] Largest BST Subtree 最大的二分搜索子树
Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest mea ...
- [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 ...
- [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 ...
- [LeetCode] Largest Number 最大组合数
Given a list of non negative integers, arrange them such that they form the largest number. For exam ...
随机推荐
- P1616 疯狂的采药(洛谷,动态规划递推,完全背包)
先上题目链接:P1616 疯狂的采药 然后放AC代码: #include<bits/stdc++.h> #define ll long long using namespace std; ...
- PyCharm开发GUI之PyQt安装
开发环境 PyCharm 2018.3.3python3.7 1 安装pyqt5 pip install PyQt5-tools 2 配置PyCharm 2.1 配置设计器 其中,program为C: ...
- [bzoj1004][HNOI2008][Cards] (置换群+Burnside引理+动态规划)
Description 小春现在很清闲,面对书桌上的N张牌,他决定给每张染色,目前小春只有3种颜色:红色,蓝色,绿色.他询问Sun有多少种染色方案,Sun很快就给出了答案.进一步,小春要求染出Sr张红 ...
- 分布式数据库中CAP原理(CAP+BASE)
分布式数据库中CAP原理(CAP+BASE) 传统的ACID 1)原子性(Atomicity): 事务里的所有操作要么全部做完,要么都不做,事务成功的条件是事务里的所有操作都成功. 2)一致性(Con ...
- windows下通过navicat for mysql连接centos6.3-64bit下的MySQL数据库
一.centos下MySQL安装 按照命令依次安装以下文件: mysql-devel 开发用到的库以及包含文件 mysql mysql 客户端 mysql-server 数据库服务器 yum inst ...
- WEB开发----springboot的登录拦截机制
如果是一个后台的管理项目的,有些东西是不能直接就可以访问的,必须要登录才可以进去,所以就需要进行登录拦截,只有登录过的用户才可以正常访问. 登录拦截是不会拦截jsp页面的方法,所以我们需要在Contr ...
- 自己修改的vim配色选择器的颜色显示部分
话不多说,上代码如下: " ___ __) ) ___ ______) " (, |/ (__/_____) /) (, / /) /) " | _/_ _ __ ___ ...
- Build Tools主流是什么?为什么要使用它?
Build Tools 即构建工具是一个把源代码生成可执行应用程序的过程自动化的程序(例如Android app生成apk).构建包括编译.连接跟把代码打包成可用的或可执行的形式. 1.构建工具的作用 ...
- Ubuntu源码下载方法
首先进入: http://cdimage.ubuntu.com/releases/ 选择相应的版本: 进入release页面: http://cdimage.ubuntu.com/releases/1 ...
- token的生成规则
1.token生成规则要添加时间戳,timestamp,以便解析token时,可以根据判断时间超过30分钟不予处理.像session过期时间一样.