**代号47 我总感觉有删节,是不是啊?

杀手

小怪 小怪
回答
  • 我已等待你很久 我已等待你很久

    include
    include
    include
    include
    using namespace std;const int maxn=100000+10;int n,top;struct node{
    int x,y;}p[maxn],point,stack[maxn];int get_cross(node a,node b,node c){
    return(b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);}
    int get_d**(node a,node b){
    return(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}
    void find_point(){
    int col=0;point=p[0];for(int i=1;i;i+){
    if(p[i].y|(p[i].y=point.y&p[i].x)){
    col=i;point=p[i];}
    }
    swap(p[0],p[col]);}
    bool cmp(node a,node b){/we sort these points as the clockw**e.
    int t=get_cross(point,a,b);if(t)return true;if(t>0)return false;int xx=get_d**(point,a),yy=get_d**(point,b);return xx;}
    void graham(){
    top=1;p[n]=p[0];stack[0]=p[0];stack[1]=p[1];for(int i=2;i;i+){/it rotates as the clockw**e.
    while(top>=1&get_cross(stack[top-1],stack[top],p[i])>=0)top-;stack[+top]=p[i];}
    }
    void rotating_colipers(){
    int ans=0,x=2;stack[top+1]=stack[0];for(int i=1;i;i+){
    while(get_cross(stack[x+1],stack[i+1],stack[i])>get_cross(stack[x],stack[i+1],stack[i])){
    x=(x+1)%(top+1);}
    ans=max(ans,get_d**(stack[x],stack[i]));ans=max(ans,get_d**(stack[x],stack[i+1]));ans=max(ans,get_d**(stack[x+1],stack[i+1]));ans=max(ans,get_d**(stack[x+1],stack[i]));}
    printf("%d",ans);}
    int main(){
    scanf("%d",&n);for(int i=0;i;i+){
    scanf("%d%d",&p[i].x,&p[i].y);}
    if(n=2)printf("%d",get_d**(p[0],p[1]));else{
    find_point();sort(p+1,p+n,cmp);graham();rotating_colipers();}
    puts("");return 0;}

类似问答
精品推荐

友情链接

友链互换QQ:

谷财 备案编号:蜀ICP备11019336号-3商务合作:235-677-2621

Copyright 2009-2020 Chengdu Sanzilewan Technology Co.,Ltd all rights reserve

抵制不良游戏 拒绝盗版游戏 注意自我保护 谨防受骗上当 适度游戏益脑 沉迷游戏伤身 合理安排时间 享受健康生活