uva 1398 - Meteor

系统 1467 0

题目链接:

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=460&page=show_problem&problem=4144



先存代码,睡觉去了 睡觉




代码:

    #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cctype>
using namespace std;

const int LCM = 2520;
const int MAXN = 100010;
int w, h, n, idx;

inline bool getTime(int x, int y, int& a, int& b){
    int tx1, tx2, ty1, ty2;
    if(a){
        tx1 = (w-x)*LCM/a, tx2 = (-x)*LCM/a;
        if(tx1<0 && tx2<0) return false;
    } else{
        if(x>=w || x<=0) return false;
        tx1 = 0,  tx2 = 1e9;
    }

    if(b){
        ty1 = (h-y)*LCM/b, ty2 = (-y)*LCM/b;
        if(ty1<0 && ty2<0) return false;

    } else{
        if(y>=h || y<=0) return false;
        ty1 = 0, ty2 = 1e9;
    }

    if(tx1 > tx2) swap(tx1, tx2);
    if(ty1 > ty2) swap(ty1, ty2);
    if(tx1<0) tx1=0;
    if(ty1<0) ty1=0;
    a = max(tx1, ty1);
    b = min(tx2, ty2);
    return a<b;
}

struct Node{
    int pos;
    int type;
    bool operator<(const Node&rhs)const{
        if(pos != rhs.pos) return pos<rhs.pos;
        return type<rhs.type;
    }
}arr[MAXN*2];


int main(){
   

    int nCase;
    scanf("%d", &nCase);
    
    while(nCase--){


        int x,y,a,b;
        scanf("%d%d%d",&w,&h,&n);

        idx = 0;
        for(int i=0; i<n; ++i){
            scanf("%d%d%d%d",&x,&y,&a,&b);
            if(getTime(x, y, a, b)){
                arr[idx].pos = a; 
                arr[idx++].type = 1;
                arr[idx].pos = b;
                arr[idx++].type = -1;
            }
        }

        sort(arr, arr+idx);

        int cur=0, maxx=0;
        for(int i=0; i<idx; ++i){
            if(arr[i].type>0) maxx = max(++cur, maxx);
            else --cur;
        }
        printf("%d\n", maxx);
    }

    return 0;
}
  




uva 1398 - Meteor


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论