71 lines
1.4 KiB
C++
71 lines
1.4 KiB
C++
|
//https://vjudge.net/contest/508277#problem/B
|
|||
|
#include<iostream>
|
|||
|
#include<cstdio>
|
|||
|
#include<cmath>
|
|||
|
#include<cstring>
|
|||
|
using namespace std;
|
|||
|
const double inf=1e100,EPS=1e-6;
|
|||
|
const int N=5e3+1;
|
|||
|
double l,now;
|
|||
|
int n,m;
|
|||
|
struct edge
|
|||
|
{
|
|||
|
int x[3],y[3],w;//int->double
|
|||
|
} a[N];
|
|||
|
#define xy x1,y1
|
|||
|
#define double int
|
|||
|
double cross(double x1,double y1,double x2,double y2)
|
|||
|
{
|
|||
|
// printf("(%d,%d)(%d,%d):%d\n",x1,y1,x2,y2,x1*y2-x2*y1) ;
|
|||
|
return x1*y2-x2*y1;
|
|||
|
}
|
|||
|
//l,rû<72><C3BB><EFBFBD><EFBFBD>
|
|||
|
void find(int l,int r,int mid,int x1,int y1)
|
|||
|
{
|
|||
|
// printf("l:%d,r:%d,mid:%d(%d,%d),x1:%d,y1:%d\n",l,r,mid,a[mid].x[0],a[0].y[0],x1,y1);
|
|||
|
if(l==r)
|
|||
|
{
|
|||
|
a[l].w++;
|
|||
|
return ;//<2F><><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>û<EFBFBD><C3BB>return
|
|||
|
}
|
|||
|
if(cross(a[mid].x[0],a[0].y[0],x1-a[mid].x[1],y1-a[0].y[1])<=0)//˳ʱ<CBB3><CAB1><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>+
|
|||
|
{
|
|||
|
find(l,mid-1,(l+mid)/2,xy);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
find(mid,r,(mid+r+1)/2,xy);
|
|||
|
}
|
|||
|
}
|
|||
|
int main()
|
|||
|
{
|
|||
|
while(1)
|
|||
|
{
|
|||
|
scanf("%d",&n);
|
|||
|
if(n==0) return 0;
|
|||
|
int x1,y1;
|
|||
|
memset(a,0,sizeof(edge)*(n+1));
|
|||
|
scanf("%d%d%d%d%d",&m,&a[0].x[1],&a[0].y[1],&a[0].x[2],&a[0].y[2]);
|
|||
|
a[0].x[2]=a[0].x[1];
|
|||
|
a[0].x[0]=a[0].x[2]-a[0].x[1];
|
|||
|
a[0].y[0]=a[0].y[2]-a[0].y[1];
|
|||
|
for(int i=1;i<=n;i++)
|
|||
|
{
|
|||
|
scanf("%d%d",&a[i].x[1],&a[i].x[2]);
|
|||
|
a[i].x[0]=a[i].x[2]-a[i].x[1];
|
|||
|
// cout<<a[i].x[0]<<"\\";
|
|||
|
}
|
|||
|
for(int i=1;i<=m;i++)
|
|||
|
{
|
|||
|
scanf("%d%d",&x1,&y1);
|
|||
|
find(0,n,(n+1)/2,xy);
|
|||
|
}
|
|||
|
for(int i=0;i<=n;i++)
|
|||
|
{
|
|||
|
printf("%d: %d\n",i,a[i].w);//Presentation Error
|
|||
|
}
|
|||
|
printf("\n"); //Presentation Error
|
|||
|
}
|
|||
|
|
|||
|
}
|