hdu 6325 Interstellar Travel (凸包)

http://acm.hdu.edu.cn/showproblem.php?pid=6325

题意:给定平面上n个点,起点横坐标最小,终点横坐标最大。每次可以飞到一个横坐标严格更大的点,代价为两个坐标的叉积。 求起点到终点总代价最小的飞行路线,并输出字典序最小的路线。

思路:因为凸包是求逆时针的时候面积包住所有点的面积最大,那么我们题目这样是顺时针,相反的就是面积最小,所以这题就是求顺时针的凸包,那肯定就包括起点、终点、凸包的拐点了,只要把上凸包求出来就好。

代码

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
#define ll long long
struct node
{
    ll x,y;
    int id;
}a[N];
int s[N];
bool cmp(node a,node b)
{
    if(a.x==b.x)
    {
        if(a.y==b.y)
        {
            return a.id<b.id;
        }
       return a.y>b.y;
    }
    else return a.x<b.x;
}
bool judge(int x,int y,int z)
{
    if((a[z].y-a[x].y)*(a[y].x-a[x].x)==(a[z].x-a[x].x)*(a[y].y-a[x].y))
        return a[z].id<a[y].id;
    if((a[z].y-a[x].y)*(a[y].x-a[x].x)>(a[z].x-a[x].x)*(a[y].y-a[x].y))
        return true;
    return false;
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
        {
            scanf("%lld%lld",&a[i].x,&a[i].y);
            a[i].id=i;
        }
        sort(a+1,a+1+n,cmp);
        int top=0;
        s[top++]=1;
        for(int i=2;i<=n;i++)
        {
            if(a[i].x==a[i-1].x&&a[i].y==a[i-1].y)
                continue;
            while(top>=2&&judge(s[top-2],s[top-1],i))
                top--;
            s[top++]=i;
        }
        for(int i=0;i<top;i++)
        {
            if(i)printf(" ");
            printf("%d",a[s[i]].id);
        }
        printf("\n");
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
How should we use data to help us analyse our beliefs? This book is concerned with the subjectivist analysis of uncertainty, and develops methods that combine prior judgements with information derived from relevant data. Whenever we move from broadly data-focused questions, such as ‘Does this data set suggest that a certain medical treatment is likely to be effective?’, to broadly decision-motivated questions, such as ‘Are we sufficiently confident, given all that we know about this treatment, to recommend its widespread use?’, then we must make such a synthesis of data with more generalized forms of information. Because we may find this hard to achieve, we need some methodology to help us. This methodology should be clear, helpful, logically well founded and tractable. The Bayesian approach to statistics is the natural methodology for this purpose. This approach treats all uncertainties within a common probabilistic framework, combining the different sources of information using the rules of probability. This approach has a sound logical foundation and a well-developed methodology and is popular and successful in many areas of application. However, in large-scale applications, the Bayesian approach can easily become the victim of its own ambition. Representing all uncertainties in probabilistic form is a daunting task for complicated problems. This is partly because of the intrinsic difficulties in judging the value of each relevant source of knowledge. However, in large part, the task is difficult because the Bayesian approach requires us to specify our uncertainties to an extreme level of detail. In practice, it is usually beyond our ability to make meaningful specifications for our joint probability distributions for multiple outcomes. If we do wish to follow a broadly Bayesian path, then we must either choose to make specifications that do not correspond to our actual uncertainties or be more modest about our ability to render our beliefs in probabilistic form. If the data are plentiful and unambiguous in their message or if the problem is not sufficiently important to merit careful analysis, then little harm is done by somewhat misrepresenting our beliefs. However, when the issue is important and data are less plentiful, then we must be more careful and honest. When we cannot make full belief specifications, we require alternative methods that respect the limitations on our abilities to specify meaningful beliefs and allow us to conduct partial analyses strictly in terms of the actual limited aspects of our beliefs that we are able to specify.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值