Created
October 1, 2019 08:44
-
-
Save lychees/0147bb293c77726015b5c890c82e50a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://paste.ubuntu.com/p/g7hk9rjTkc | |
#include<bits/stdc++.h> | |
#define mset(a,b) memset(a,b,sizeof(a)) | |
using namespace std; | |
const int N=2e3+50; | |
long long xx[N],yy[N]; | |
//long long qx[N],qy[N]; | |
long long res[N]; | |
struct Point //向量,但是主要判断方向与自己平行的多少个 | |
{ | |
long long x,y; | |
Point() {} | |
Point(long long x,long long y):x(x),y(y) {} | |
Point operator -(const Point & o) | |
{ | |
return Point(x-o.x,y-o.y); | |
} | |
Point to()const// | |
{ | |
if(x<0||(x==0&& y < 0 )) return Point(-x,-y); | |
return Point(x,y); | |
} | |
long long operator ^(const Point &o) | |
{ | |
return x*o.y-y*o.x; | |
} | |
bool operator < ( const Point& o) const//极角排序 | |
{ | |
return (to()^o.to())>0; | |
} | |
} q[N],a[N]; | |
map<Point,long long > mmp; | |
int main() | |
{ | |
ios::sync_with_stdio(false); | |
cin.tie(0); | |
cout.tie(0); | |
long long n,m; | |
while(cin>>n>>m) | |
{ | |
for(long long i=1; i<=n; ++i) | |
cin>>a[i].x>>a[i].y; | |
for(long long i=1; i<=m; ++i) | |
{ | |
mmp.clear(); | |
res[i]=0; | |
cin>>q[i].x>>q[i].y; | |
for(long long j=1; j<=n; ++j) | |
{ | |
Point p=q[i]-a[j]; | |
mmp[p]++; | |
} | |
for(long long j=1; j<=n; ++j) | |
{ | |
Point p=q[i]-a[j]; | |
p=Point(-p.y,p.x); | |
res[i]+=mmp.count(p)?mmp[p]:0; | |
} | |
res[i]/=2; | |
} | |
for(long long i=1; i<=n; ++i) //对于第i个点垂点 | |
{ | |
mmp.clear(); | |
for(long long j=1; j<=n; ++j) | |
if(i!=j) | |
mmp[Point(a[i]-a[j])]++; | |
for(long long j=1; j<=m; ++j) | |
{ | |
Point p=q[j]-a[i]; | |
p=Point(-p.y,p.x); | |
res[j]+=mmp.count(p)?mmp[p]:0; | |
} | |
} | |
for(long long i=1; i<=m; ++i) | |
cout<<res[i]<<endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment