Spinach Pizza
Contest: SWERC 2022-2023 - Online Mirror (Unrated, ICPC Rules, Teams Preferred)
Difficulty rating: 2500
Tags: games, geometry, greedy, interactive

The two siblings Alberto and Beatrice have to eat a spinach pizza together. However, none of them likes spinach, so they both want to eat as little as possible.

The pizza has the shape of a strictly convex polygon with $$$n$$$ vertices located at integer coordinates $$$(x_1, y_1), \, (x_2, y_2), \, \dots, \, (x_n, y_n)$$$ of the plane.

The siblings have decided to eat the pizza in the following way: taking turns, starting with Alberto, each sibling chooses a vertex of the remaining part of the pizza and eats out the triangle determined by its two neighboring edges. In this way, after each of the first $$$n - 3$$$ turns the pizza will have one less vertex. The game ends after the $$$(n - 2)$$$-th turn, when all the pizza has been eaten.

Assuming that Alberto and Beatrice choose the slices to eat optimally, which of the siblings manages to eat at most half of the pizza? You should identify a sibling that has a strategy to do so and help them choose the slices appropriately. Note that it is possible that both Alberto and Beatrice end up eating exactly half of the area if they choose their slices optimally.

Input format:
The first line contains a single integer $$$n$$$ ($$$4 \le n \le 100$$$) — the number of vertices.

The next $$$n$$$ lines contain two integers $$$x_i$$$ and $$$y_i$$$ each ($$$-10^6 \le x_i, y_i \le 10^6$$$) — the coordinates of the $$$i$$$-th vertex of the polygon representing the initial shape of the pizza.

It is guaranteed that the polygon is strictly convex and that its vertices are given in counterclockwise order.

Interaction format:
First, you should print a line containing either the string $$$\texttt{Alberto}$$$ or the string $$$\texttt{Beatrice}$$$ — the sibling that you will help to win.

Then, for the next $$$n - 2$$$ turns, you will alternate with the judge in choosing a slice of the pizza and removing it, starting with you if you chose to help Alberto, or starting with the judge if you chose to help Beatrice.

- When it is your turn, print a single line containing an integer $$$p$$$ ($$$1 \leq p \leq n$$$) that has not been chosen before, indicating that you want to eat the slice determined by the vertex located at $$$(x_p, y_p)$$$.
- When it is the judge's turn, read an integer $$$q$$$ ($$$1 \leq q \leq n$$$), indicating that the other player eats the slice determined by the vertex located at $$$(x_q, y_q)$$$. It is guaranteed that $$$q$$$ has not been chosen before.

If one of your interactions is malformed, the interactor terminates immediately and your program receives the verdict $$$\texttt{WRONG-ANSWER}$$$. Otherwise, you will receive $$$\texttt{CORRECT}$$$ if at the end your player has eaten at most half of the pizza, and $$$\texttt{WRONG-ANSWER}$$$ otherwise.

After printing a line do not forget to end the line and flush the output. Otherwise, you will get the verdict $$$\texttt{TIMELIMIT}$$$. To flush the output, use:

- $$$\texttt{fflush(stdout)}$$$ in C;
- $$$\texttt{fflush(stdout)}$$$, $$$\texttt{cout <}\texttt{< flush}$$$ or $$$\texttt{cout.flush()}$$$ in C++;
- $$$\texttt{System.out.flush()}$$$ in Java and Kotlin;
- $$$\texttt{sys.stdout.flush()}$$$ in Python.

Constraints:
Time limit: 2.0 s
Memory limit: 256.0 MB

Note:
In the first sample, the pizza has area $$$15$$$. Alberto can eat less than half of the pizza by eating the slice around vertex $$$2$$$ (which has area $$$6.5$$$) or around vertex $$$3$$$ (which has area $$$3.5$$$).

In the second sample, it can be proved that both players will eat exactly half of the pizza if they eat optimally. Therefore it is possible to choose to help either Alberto or Beatrice.

In the third sample, it is possible to show that only Beatrice has a strategy to eat at most half of the pizza. The following is an example of a valid interaction (after reading the input):

$$$$$$ \begin{array}{|c|c|c|} \hline \textbf{Contestant} & \textbf{Judge} & \textbf{Explanation} \\ \hline \texttt{Beatrice} & & \text{The contestant will help Beatrice} \\ \hline & \texttt{7} & \text{Alberto eats the triangle with vertices $6$, $7$, $1$ and area $1$} \\ \hline \texttt{2} & & \text{Beatrice eats the triangle with vertices $1$, $2$, $3$ and area $2$} \\ \hline & \texttt{5} & \text{Alberto eats the triangle with vertices $4$, $5$, $6$ and area $1.5$} \\ \hline \texttt{4} & & \text{Beatrice eats the triangle with vertices $3$, $4$, $6$ and area $8$} \\ \hline & \texttt{6} & \text{Alberto eats the triangle with vertices $3$, $6$, $1$ and area $11$} \\ \hline \end{array} $$$$$$ The total area eaten by Alberto is $$$13.5$$$ and the total area eaten by Beatrice is $$$10$$$, which is less than half the area of the whole pizza. The actions performed by the contestant and the judge in this example of interaction may be non-optimal. The process is illustrated below:

Example input:
4
0 0
6 1
5 3
1 4

Example output:
-

Example input:
6
0 0
2 0
3 2
2 4
0 4
-1 2

Example output:
-

Editorial:
This problem has a greedy solution. The idea is that, at any moment, if the player who has to eat picks the triangle with smallest area among those that can be eaten in that moment, then any triangle chosen later will have area not less than it.
Therefore if $$$n$$$ is even, Alberto can win by choosing the smallest possible slice at each turn, since the quantity eaten by Beatrice in the next turn will always be greater or equal and thus, since they eat the same number of slices, Alberto will eat no more in total. On the other hand, for $$$n$$$ odd, no matter what slice Alberto chooses at the beginning, Beatrice can apply the explained strategy for the remaining number of turns, which is even. In this case Alberto will eat the initial amount plus at least the quantity Beatrice eats in the remaining turns, and therefore a total area strictly bigger than hers.
Now we prove the above claim. More precisely, given a convex polygon with vertices $$$P_1, \ldots, P_n$$$, the minimum area of any triangle with vertices $$$P_i, P_j, P_k$$$ is attained by a triangle determined by two consecutive edges in the polygon (we will call such triangles edible). Given a non-edible triangle, it is clear that we can label its vertices $$$P, Q$$$ and $$$R$$$ in such a way that neither of the edges $$$PR$$$ and $$$QR$$$ belong to the polygon. Then it is enough to show that we can change $$$R$$$ by a vertex adjacent to $$$P$$$ or $$$Q$$$ and the remaining triangle will have at most the initial area. Indeed, by repeating this argument at most twice we can start with any triangle and obtain an edible triangle without increasing its area.
Let $$$A$$$ and $$$B$$$ be the vertices in the same side of the line $$$PQ$$$ as $$$R$$$ which are adjacent to $$$P$$$ and $$$Q$$$, respectively. Then one of the triangles $$$PQA$$$ or $$$PQB$$$ has less area than $$$PQR$$$: since they all have the common base $$$PQ$$$, the area is proportional to the height with respect to the line $$$PQ$$$. However, if the height of $$$R$$$ were less than that of $$$A$$$ and $$$B$$$, then we would be able to write $$$R$$$ as a convex combination of $$$A, B, P$$$ and $$$Q$$$, which contradicts the strict convexity of the polygon.