room [判断点与线的关系]


点击打开链接

时间限制: 1 Sec   内存限制: 64 MB
提交: 16   解决: 13
[ 提交][ 状态][ 讨论版]

题目描述

The ACM / ICPC team has a large room, the length and width of which is 10^6 . However, the guys in ACM / ICPC teams are too lazy to make their study room tidy. So there are wires everywhere and divide the room into several parts. A team in a part of the room cannot move out of it or they might touch the wires and the network will down. To make every team can compete in the contest, they have to set up some facilities such as toilet since the teams should do anything in their parts. Now, we will give you the map of our study room and the position of the teams, your task is to calculate how many facilities is required to let every team can access a facilities to finish the contest without move out of their part. You should note that two or more teams can share a facility. 

输入

输出

Output one integer, the minimal facilities required.

样例输入

3
0 200000 1000000 600000
600000 0 300000 1000000
0 800000 1000000 400000
9
200000 900000
200000 400000
300000 600000
600000 500000
700000 700000
800000 300000
300000 200000
800000 100000
600000 200000

样例输出

6

提示



题意:

给你n条线,把整个地图分成若干份,

然后给你m个队伍。 问你这些队伍最多占领了地图的多少份,


题解:

一个点与线的关系只有三种,而题中保证不在线上,那只有线上方or 下方。

然后对线排个序,然后求出一个点到所有线的关系,存进string 然后用set统计即可。


、、

#include<string>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<set>
#define ll long long
#define x first
#define y second
using namespace std;
const int mod=11;
const int maxn=100100;
const int maxm=111;
typedef pair<ll,ll>point;
typedef pair<point,point>li;
li line[maxn];
set<string>s;
int n,m;

int judge(li a,point p){
    ll A=a.second.y-a.first.y;
    ll B=a.first.x-a.second.x;
    ll C=A*a.first.x+B*a.first.y;
    return p.x*A+p.y*B-C>0;
}
int main(){
    scanf("%d",&n);
    point p1,p2,p3;
    for(int i=1;i<=n;++i){
        scanf("%lld %lld %lld %lld",&p1.x,&p1.y,&p2.x,&p2.y);
        line[i].x=p1,line[i].y=p2;
    }
    scanf("%d",&m);
    for(int i=1;i<=m;++i){
        scanf("%lld %lld",&p1.x,&p1.y);
        string str="";
        for(int j=1;j<=n;++j){
            str+=judge(line[j],p1)+'0';
        }
        s.insert(str);
    }
    printf("%d\n",s.size());
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值