问题 G: Room
时间限制: 1 Sec 内存限制: 64 MB提交: 15 解决: 12
[ 提交][ 状态][ 讨论版]
题目描述
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.
输入
![](http://acm.codedream.ren/JudgeOnline/upload/image/20170417/20170417085232_24412.png)
输出
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个起始点和终止点,保证每个点都在边上,每两个点连成一条线,把矩形分成若干个区域,现在有t个点有人,在有人的区域内建设服务点
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<set>
#include<math.h>
using namespace std;
#define ll long long
set<string>s3;
struct node
{
int x1,y1,x2,y2;
}s[100005];
struct ha
{
int x,y;
}s1[105];
ll judge(node a,ha b)
{
ll A=a.y2-a.y1;
ll B=a.x1-a.x2;
ll c=(-B*a.y1-A*a.x1);
return A*b.x+B*b.y+c>0;
}
int solve(int n,int m)
{
for(int i=1;i<=m;i++)
{
string ch=" ";
for(int j=1;j<=n;j++)
{
ch+=judge(s[j],s1[i])+'0';
}
s3.insert(ch);
}
return s3.size();
}
int main()
{
int n;
while(scanf("%d",&n)!=-1)
{
for(int i=1;i<=n;i++)
{
scanf("%d%d%d%d",&s[i].x1,&s[i].y1,&s[i].x2,&s[i].y2);
}
int m;
scanf("%d",&m);
for(int i=1;i<=m;i++)
{
scanf("%d%d",&s1[i].x,&s1[i].y);
}
printf("%d\n",solve(n,m));
}
}