传送门

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

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

我们可以先把所有的边都取出来,然后按极角排序。枚举这个凸包的起点,然后做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. 洛谷——P1342 请柬

    P1342 请柬 题目描述 在电视时代,没有多少人观看戏剧表演.Malidinesia古董喜剧演员意识到这一事实,他们想宣传剧院,尤其是古色古香的喜剧片.他们已经打印请帖和所有必要的信息和计划.许多学 ...

  2. UVA-12333 Revenge of Fibonacci(竖式加法模拟 & 字典树)

    题目: 给出一个斐波那契数字的前缀,问第一个有这个前缀的数字在斐波那契数列中是第几个. 思路: 紫书提示:本题有一定效率要求.如果高精度代码比较慢,可能会超时. 利用滚动数组和竖式加法来模拟斐波那契相 ...

  3. Libreswan软件的密钥协商协议IKEv1主模式实现分析

    Libreswan软件的密钥协商协议IKEv1主模式实现分析 1 协商过程 IKEv1(互联网密钥交换协议第一版)是IPsec VPN隧道协商使用的标准密钥协商协议,其协商过程如下图所示. 总共来回交 ...

  4. OS X中微信双开

    1.打开系统终端: 2.下载插件,输入命令(不包括括号) git clone https://github.com/Sunnyyoung/WeChatTweak-macOS.git 并回车: 3.进入 ...

  5. 3. Python中的分支判断、循环

    本文利用的是Python 3.x版本,建议学习3.x版本 Python中的分支判断.循环 1. 分支条件判断 1.1 比较操作 以下是数之间常见的比较操作,例如5>3就是数学意义上的比较,5是大 ...

  6. PAT 1020. Tree Traversals

    PAT 1020. Tree Traversals Suppose that all the keys in a binary tree are distinct positive integers. ...

  7. 洛谷 P1877 BZOJ 2748 cogs 791 [HAOI2012]音量调节

    题目描述 一个吉他手准备参加一场演出.他不喜欢在演出时始终使用同一个音量,所以他决定每一首歌之前他都需要改变一次音量.在演出开始之前,他已经做好一个列表,里面写着每首歌开始之前他想要改变的音量是多少. ...

  8. md5加密的工具类(from 韩顺平)

    输入一个字符串,然后可以进行md5加密 import java.security.*; import java.security.spec.*; public class MyTools { publ ...

  9. codevs1018 单词接龙

    题目描述 Description 单词接龙是一个与我们经常玩的成语接龙相类似的游戏,现在我们已知一组单词,且给定一个开头的字母,要求出以这个字母开头的最长的“龙”(每个单词都最多在“龙”中出现两次), ...

  10. codevs——1530 大质数

    1530 大质数  时间限制: 1 s  空间限制: 1000 KB  题目等级 : 黄金 Gold 题解       题目描述 Description 小明因为没做作业而被数学老师罚站,之后数学老师 ...