Rotate the Polyline SOLUTION
Gourmet specialist John is given a polyline P comprising of focuses P1…Pn. Assist him with finding a vector v, to such an extent that the accompanying holds:
Let Si=dot(v,PiPi+1−→−−−) (here Pn+1=P1).
There exists three numbers w,l,r, with the end goal that:
For all i,l≤i≤r,Si⋅w>0
For all different estimations of i,Si⋅w<0
Outright estimations of v directions ought not exeed 2⋅109
Just if no such v exists it very well may be (0,0).
There are T polylines John is keen on finding the appropriate response.
All focuses Pi are one of a kind.
N≤1000 (50 focuses) (3s time limit)
N≤100000 (50 focuses) (5s time limit)
The primary line will contain T, the quantity of tests. Each test will have the accompanying configuration.
The primary line of each test will contain N, the quantity of polyline vertices.
N following lines will contain two numbers (Pi)x and (Pi)y indicating a state of a polyline.
Yield T lines with two numbers in every x and y to such an extent that v=(x,y). In the event that various answers exist you can print any of them.
1 – 1
– 5 1
2 – 1