poj2187(凸包)

Beauty Contest
Time Limit: 3000MS Memory Limit: 65536K
Total Submissions: 39026 Accepted: 12099

Description

Bessie, Farmer John's prize cow, has just won first place in a bovine beauty contest, earning the title 'Miss Cow World'. As a result, Bessie will make a tour of N (2 <= N <= 50,000) farms around the world in order to spread goodwill between farmers and their cows. For simplicity, the world will be represented as a two-dimensional plane, where each farm is located at a pair of integer coordinates (x,y), each having a value in the range -10,000 ... 10,000. No two farms share the same pair of coordinates. 

Even though Bessie travels directly in a straight line between pairs of farms, the distance between some farms can be quite large, so she wants to bring a suitcase full of hay with her so she has enough food to eat on each leg of her journey. Since Bessie refills her suitcase at every farm she visits, she wants to determine the maximum possible distance she might need to travel so she knows the size of suitcase she must bring.Help Bessie by computing the maximum distance among all pairs of farms. 

Input

* Line 1: A single integer, N 

* Lines 2..N+1: Two space-separated integers x and y specifying coordinate of each farm 

Output

* Line 1: A single integer that is the squared distance between the pair of farms that are farthest apart from each other. 

Sample Input

4
0 0
0 1
1 1
1 0

Sample Output

2

Hint

Farm 1 (0, 0) and farm 3 (1, 1) have the longest distance (square root of 2) 

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;
struct Point{  
    double x,y;  
    Point(){}  
    Point(double _x,double _y){ x=_x; y=_y; }  
    Point operator + (Point p){ return Point(x+p.x,y+p.y); }  
    Point operator - (Point p){ return Point(x-p.x,y-p.y); }  
    Point operator * (double d){ return Point(d*x,d*y); }  
    double dot(Point p){ return x*p.x+y*p.y; }  //内积  
    double det(Point p){ return x*p.y-p.x*y; }  //外积 
}ps[50005];
int n;
bool cmpxy(const Point &p,const Point &q){  //排序 
    if(p.x!=q.x) return p.x<q.x;  
    return p.y<q.y;  
}  
vector<Point> convex_hull(Point *ps,int n){   
    sort(ps,ps+n,cmpxy);  
    int k=0;  
    vector<Point> qs(n*2);    //构造中的凸包  
    for(int i=0;i<n;++i){    //构造凸包的下侧  
        while(k>1 && (qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)--k;
        qs[k++]=ps[i];  
    }  
    for(int i=n-2,t=k;i>=0;--i){ //构造凸包的上侧  
        while(k>t && (qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)--k;
        qs[k++]=ps[i];  
    }  
    qs.resize(k-1);  
    return qs;  
}  
double dist(Point p,Point q){  //两点距离平方 
    return (p-q).dot(p-q);  
}
void solve()
{
	vector<Point> qs=convex_hull(ps,n);
	double res=0;
	for(int i=0;i<qs.size();i++)
		for(int j=0;j<i;j++)
			res=max(res,dist(qs[i],qs[j]));
	printf("%.0f\n",res);
}  
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lf%lf",&ps[i].x,&ps[i].y);
	}
	solve();
}



内容概要:本文详细介绍了深度学习的基本概念和技术要点,涵盖了从基础知识到高级模型的多个方面。首先,文中强调了激活函数与权重初始化的最佳实践,如ReLU搭配He初始化,Sigmoid或Tanh搭配Xavier初始化。接着,文章系统地讲解了深度学习所需的数学基础(线性代数、微积分、概率统计)、编程技能(Python、PyTorch/TensorFlow)以及机器学习基础(监督学习、无监督学习、常见算法)。此外,还深入探讨了神经网络的核心组件,包括前向传播、反向传播、激活函数、优化算法、正则化方法等,并特别介绍了卷积神经网络(CNN)、循环神经网络(RNN)、长短期记忆网络(LSTM)、注意力机制(Attention)、Transformer架构及其衍生模型(BERT、GPT)。最后,文章讨论了大模型训练、分布式训练、模型压缩、Prompt Engineering、文本生成、多模态学习等前沿话题,并提供了学习资源推荐。 适合人群:对深度学习有一定兴趣并希望深入了解其原理的研究人员、工程师或学生,尤其是那些具备一定编程基础和数学知识的人群。 使用场景及目标:①帮助读者理解深度学习中的关键概念和技术细节;②指导读者如何选择合适的激活函数和权重初始化方法;③为读者提供构建和优化神经网络模型的实际操作指南;④介绍最新的研究进展和发展趋势,拓宽读者视野。 其他说明:建议读者在学习过程中结合实际案例进行练习,积极尝试文中提到的各种技术和工具,同时关注领域内的最新研究成果,以便更好地掌握深度学习的应用技巧。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值