zoukankan      html  css  js  c++  java
  • POJ 1410 计算几何

    思路:

    快速排斥实验+跨立实验

    注意矩形是实心的,即在内部也算相交。

    //By SiriusRen
    #include <cstdio>
    #include <algorithm>
    using namespace std;
    int cases,xs,ys,xe,ye,xl,yt,xr,yb;
    bool chaji(int x1,int y1,int x2,int y2){return x1*y2-x2*y1>=0;}
    bool kl(int x1,int y1,int x2,int y2){
        return chaji(xs-x1,ys-y1,x2-x1,y2-y1)!=chaji(xe-x1,ye-y1,x2-x1,y2-y1)
             &&chaji(x1-xs,y1-ys,xe-xs,ye-ys)!=chaji(x2-xs,y2-ys,xe-xs,ye-ys);
    }
    bool check(int x1,int y1,int x2,int y2){
        int Y1=min(ys,ye),Y2=max(ys,ye);
        int minx=max(x1,xs),maxx=min(x2,xe);
        int miny=max(Y1,y1),maxy=min(Y2,y2);
        return minx<=maxx&&miny<=maxy&&kl(x1,y1,x2,y2);
    }
    bool ck2(){return xl<=xs&&yb<=ys&&xr>=xe&&yt>=ye;}
    signed main(){
        scanf("%d",&cases);
        while(cases--){
            scanf("%d%d%d%d%d%d%d%d",&xs,&ys,&xe,&ye,&xl,&yt,&xr,&yb);
            if(xs>xe)swap(xs,xe),swap(ys,ye);
            if(xl>xr)swap(xl,xr);if(yt<yb)swap(yt,yb);
            if(check(xl,yt,xr,yt)||check(xl,yb,xr,yb)||check(xl,yb,xl,yt)||check(xr,yb,xr,yt)||ck2())puts("T");
            else puts("F");
        }
    }
  • 相关阅读:
    移动端图片按比例裁剪
    bootstrap悬停下拉菜单显示
    videojs兼容ie8
    ie浏览器不支持多行隐藏显示省略号
    rem和px
    浏览器默认返回,页面刷新
    centos src compile gcc 7.3
    docker与gosu
    centos 安装 kernel
    docker proxy
  • 原文地址:https://www.cnblogs.com/SiriusRen/p/9381990.html
Copyright © 2011-2022 走看看