#P6612. [POI 2012] LIC-Bidding
[POI 2012] LIC-Bidding
Background
This is an interactive problem.
The checker contains the official solution, so it is not provided.
Problem Description
Two players, A and B, are playing a game. They take turns operating on a pair of integers .
Initially, . There are three possible operations:
- Change to .
- Change to .
- Change to .
A positive integer is given. When , the last two operations cannot be performed. If after a player makes a move, , then that player loses.
It is guaranteed that the given is a winning position for the first player. You need to provide a winning strategy for the first player. For example, when , the first player chooses operation 3. Then the second player can only choose operation 1 and loses, so the first player wins for .
Interactive problem. You need to implement a function extern "C" int _opt(int n, int x, int y). The return value of this function is an integer equal to , , or , indicating which operation you will choose when the current pair is , the parameter is , and it is your turn.
Hint
Constraints
For all test points, it is guaranteed that .
Notes
A sample interaction library is provided in the attachment. After compiling it locally together with the contestant program, you can use standard input to simulate the interaction between the special judge (spj) and the contestant program.
When the interaction library outputs -2 -2 and exits, it means the contestant program is correct.
Translated by ChatGPT 5