Rotate the Polyline SOLUTIONS ROTATPOL

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 dot((a,b),(x,y))=a⋅x+b⋅y 
 
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. 
 
Requirements: 
 
1≤T≤5 
 
3≤N≤105 
 
|(Pi)x|,|(Pi)y|≤5⋅108 
 
All focuses Pi are one of a kind. 
 
Subtasks: 
 
N≤1000 (50 focuses) (3s time limit) 
 
N≤100000 (50 focuses) (5s time limit) 
 
Information: 
 
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 
 
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. 
 
Test Input: 
 
 
 
 
1 – 1 
 
2 3 
 
4 0 
 
3 7 
 
 
 
0 1 
 
 
1 0 
 
Test Output: 
 
– 5 1 
 
2 – 1
 

Leave a Comment

close
error: Content is protected !!