Triangle Game
Practice
1 (1 votes)
Geometry
Mathematics
Approved
Game theory
Easy Medium
Problem
21% Success 503 Attempts 30 Points 5s Time Limit 512MB Memory 1024 KB Max Code

Alice and Bob are playing a game on a set of points in the 2 dimensional plane.

Initially, there are N points.

In the beginning, 3 points are chosen as starting points to make the initial triangle of the game. These three points must not be collinear, and all points that lie on the boundary of the triangle or outside this triangle are erased.

Alice and Bob then play a game on this initial triangle and remaining points with Alice going first.

On a player's turn, the player first chooses a triangle(say \(\Delta ABC\)) which is still in the game and has at least one point strictly inside.
Then the player chooses any point P strictly inside the \(\Delta ABC\). \(\Delta ABC\) is now removed from the game. The move introduces 3 new smaller triangles \(\Delta ABP\), \(\Delta APC\) and \(\Delta PBC\) into the game. The game continues on the remaining points and triangles.

The loser of the game is the one who is unable to move on their turn.

Given the set of points, compute the number of initial three points such that Alice wins if both players play optimally. Two initial sets of points are different if the unordered sets of the points are different.

Input Format:

The first line will contain the number of test cases T.
Each test case will be formatted as follows.
The first line will contain a single integer N.
The next N lines will describe two integers \(x_i, y_i\) denoting the coordinates of a point in the 2 dimensional plane.

Output Format:

Output T numbers, the number of initial configurations that lead to a win for Alice.

Constraints

For all subtasks:
\(T ≤ 100\)
\(0 ≤ x_i,y_i ≤ 10^9\)
\(3 ≤ N\)

File 1 (60 pts)
\(N ≤ 7\)

File 2 (40 pts)
\(N ≤ 30\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
17 votes
Tags:
Dynamic ProgrammingAlgorithmsEasy-MediumMathematicsOpenApprovedGame Theory
Points:30
3 votes
Tags:
MathematicsPrime FactorizationEasy-MediumGame TheoryNumber Theory