Point normalize()const { if (x < 0 || (x == 0 && y < 0)) returnPoint(-x, -y); return *this; }
Point operator-(const Point &other) const { returnPoint(x - other.x, y - other.y); } booloperator<(const Point &other) const { //将线按照斜率排序,以在map中统计到一起。 Point a = normalize(), b = other.normalize(); return a.y * b.x < b.y * a.x; } }; using Vec = Point;
Point origin[MAXN],queries[MAXN]; int ans[MAXN]; map<Vec,int> mp;
intmain() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int nlen, qlen; while (cin >> nlen >> qlen) { memset(ans,0,sizeof(ans)); for (int i = 0; i < nlen; i++) { cin>>origin[i].x>>origin[i].y; } for (int i = 0; i < qlen; i++) { cin>>queries[i].x>>queries[i].y; }
for (int i = 0; i < nlen; i++) { mp.clear(); for (int j = 0; j < nlen; j++) { if (i == j) continue; Vec temp = origin[j] - origin[i]; mp[temp]++; } for (int j = 0; j < qlen; j++) { Vec temp = queries[j] - origin[i]; ans[j] += mp[Vec(-temp.y, temp.x)]; } } /* cout<<"====not===="<<endl; for(int i=0;i<qlen;i++){ cout<<ans[i]<<"\t"; } cout<<endl<<"====not===="<<endl; */
for (int i = 0; i < qlen; i++) { mp.clear(); for (int j = 0; j < nlen; j++) { Vec temp = origin[j] - queries[i]; ans[i] += mp[Vec(-temp.y, temp.x)]; mp[temp]++; } }
for (int i = 0; i < qlen; i++) { cout << ans[i] << "\n"; } }