hdu 6325 - 凸包面积

题目链接:点击这里

 

解题思路:

实际上是求从第一个点出发逆时针路径到达最后一个点的凸包,其实一个细节就是凸包上的点上,三点共线的中间那个点是否要删除?那就看他后面的那个点的下标是否小于它,小于的话删除之后字典序就更小了。

 

#include<bits/stdc++.h>
using namespace std;
const int mx = 2e5 + 10;
typedef long long ll;
int n,m,ans[mx],top,ma;
struct node
{
    int x,y;
    int pos;
}s[mx],tubeg[mx],w;
bool vis[mx];
ll judge(node p1,node p2,node p0)//面积公式判断正负值 
{
    ll ans = 1ll*(p1.x-p0.x)*(p2.y-p0.y) - 1ll*(p2.x-p0.x)*(p1.y-p0.y);
    return ans; 
}
bool cmp(node a,node b)
{
    ll c = judge(w,b,a);//极角排序,同角度按距离从小到大排 
    if(b.x==a.x&&b.y==a.y) return a.pos > b.pos;
    if(!c) return pow(a.x-w.x,2)+pow(a.y-w.y,2) < pow(b.x-w.x,2)+pow(b.y-w.y,2);
    return c > 0;
}
void Graham()
{
    tubeg[0] = s[0],tubeg[1] = s[1];
    top = 2;
    for(int i=2;i<n;i++)
    {
        while(top>1&&judge(tubeg[top-2],s[i],tubeg[top-1])<=0)
        {
            if(judge(tubeg[top-2],s[i],tubeg[top-1])<0||tubeg[top-1].pos>s[i].pos) top--;
            else break;
        }
        tubeg[top++] = s[i];
    }
    for(int i=0;i<top;i++) printf("%d%c",tubeg[i].pos+1,i==top-1?'\n':' ');
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        memset(vis,0,sizeof(vis));
        for(int i=0;i<n;i++){
            scanf("%d%d",&s[i].x,&s[i].y);
            s[i].pos = i; 
        }
        w = s[0];
        sort(s+1,s+n,cmp);
        Graham();
    }
    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、付费专栏及课程。

余额充值