Topic links: https://ac.nowcoder.com/acm/contest/883/H
Meaning of the questions:
You give an even number of coordinates of points, to identify a line number these points into n number of equal portions of two
And takes two different points on this line, this line represents
Ideas:
See the first reaction this problem is to first set a relatively fixed points at infinity
Then take over sweep, one takes a point, one can find these points is divided into m and m + 1 points
Finally, the slope slightly tilted, and then take it on a line to
Finally crazy WA, do not know the problem or algorithm code issues
After listening to explain the big brother, I found myself really stupid
Last practice:
These coordinates x n points by small to large, x coordinates with the same y-coordinate by ascending sort
This allows to find a center-left point p (x0, y0), taking a vertical straight line x = x0
Then these straight lines of vertical, the center point p is a little rotated counterclockwise
The answer is provided two o'clock a (x1, y2), b (x2, y2), so that x1 = x0-1, x2 = x0 + 1, y1 = y0 + 1000000, y2 = y0-1000000 can be achieved
This will be divided into m points and the point m + 1
Finally, a point remains fixed, will move a unit length y2 = y2 + 1 on the point b
That the point p can also fall below a straight line, into an equal number of piles success
Sigh again their own good fishing qaq
1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 #define e 990000000 5 6 struct point{ 7 int x,y; 8 }p[1006]; 9 10 bool cmp(point a,point b){ 11 if(a.x==b.x) 12 return a.y<b.y; 13 return a.x<b.x; 14 } 15 16 int main() 17 { 18 int n,m,t,x1,x2,y1,y2; 19 cin>>t; 20 while(t--){ 21 cin>>n; 22 for(int i=0;i<n;i++) 23 cin>>p[i].x>>p[i].y; 24 sort(p,p+n,cmp); 25 int m=n/2-1; 26 x1=p[m].x-1,x2=p[m].x+1,y1=p[m].y+e,y2=p[m].y-e+1; 27 printf("%d %d %d %d\n",x1,y1,x2,y2); 28 } 29 return 0; 30 }