Problem Statement | |||||||||||||
NOTE: This problem statement contains subscripts and superscripts that may not appear correct when viewed outside of the contest applet. You are playing a game with a flat board on top of a thin post. On this board are items of various weights, placed in a such a manner that the board balances on top of the post. You and your opponent take turns removing items from the board. If at any time the board falls off the post, whoever removed the last item causing the board to fall loses. If all objects are removed without the board falling, the player who moved first loses. The board balances if the magnitude of the total torque due to the weight of all objects upon it does not exceed a given threshold. The torque due to a single object is a vector in the plane of the board, computed as: (Tx,Ty) = (-y*w,x*w) Where x and y are the position of the object, and w is its weight. Assume the board is centered on the post, and that the torque due to its own weight is zero. The total torque is the sum of the torque vectors for each object, and the magnitude is the length of that sum. The position and weight of the objects will be given by three int[] parameters: x, y, and w. x[i], y[i] gives the position of object i, and w gives its weight. The x,y coordinates are relative to the origin, the point where the board rests on the post. Multiple objects can not have the same position on the board. Return a list of all the objects that the first player could remove on his first turn in order to win the game, assuming that both players play optimally. The return value should be a int[], where each element corresponds to an entry in the x, y, and w int[]s. The elements should be sorted in ascending order. If there are no possible winning moves, return an empty int[]. If the initial state of the board is unbalanced, it will fall before the first player has a chance to make a move. In this case, return { -1 }. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | (x1, y1) + (x2, y2) = (x1 + x2, y1 + y2). | ||||||||||||
- | The square of the length of (x, y) is x2 + y2. | ||||||||||||
Constraints | |||||||||||||
- | x will contain between 1 and 20 elements, inclusive. | ||||||||||||
- | x, y, and w will all contain the same number of elements. | ||||||||||||
- | Each element of x and y will be between -100 and 100, inclusive. | ||||||||||||
- | Each element of w will be between 1 and 100, inclusive. | ||||||||||||
- | threshold will be between 0 and 1000000000, inclusive. | ||||||||||||
- | No two objects will occupy the same position. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|