#P6612. [POI 2012] LIC-Bidding

    ID: 7363 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2012POI(波兰)交互题Special JudgeO2优化

[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 (x,y)(x, y).

Initially, (x,y)=(1,0)(x, y) = (1, 0). There are three possible operations:

  1. Change (x,y)(x, y) to (1,x+y)(1, x + y).
  2. Change (x,y)(x, y) to (2x,y)(2x, y).
  3. Change (x,y)(x, y) to (3x,y)(3x, y).

A positive integer nn is given. When x+ynx + y \ge n, the last two operations cannot be performed. If after a player makes a move, yny \ge n, then that player loses.

It is guaranteed that the given nn is a winning position for the first player. You need to provide a winning strategy for the first player. For example, when n=3n = 3, the first player chooses operation 3. Then the second player can only choose operation 1 and loses, so the first player wins for n=3n = 3.

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 11, 22, or 33, indicating which operation you will choose when the current pair is (x,y)(x, y), the parameter is nn, and it is your turn.

Hint

Constraints

For all test points, it is guaranteed that 1n300001 \le n \le 30000.

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