#P10609. 排除干扰
排除干扰
Description
This is an interactive problem.
To analyze from both perspectives, Renko imagines a game between Little R and Little M, with the following rules:
Both Little R and Little M initially have cards, categorized into types numbered to . Each type has at least one card initially for both players. They can see each other's cards.
They take turns discarding cards, with Little R going first. Each turn, they discard exactly one card. When both are left with one card each—suppose Little R's card is and Little M's is —Little R's score is , and Little M's score is . Both aim to maximize their own scores.
You will simulate a game with the interactor. If , you play as Little R; if , you play as Little M. Your score must meet or exceed the optimal score when both play optimally.
Input Format
- The first line contains three integers , , , as described.
- The next lines each contain integers, representing matrix . The -th row and -th column is .
- The next two lines each contain integers:
- The first line: denotes Little R's initial count of type cards.
- The second line: denotes Little M's initial count of type cards.
It is guaranteed that .
Interaction Process:
- If it is the opponent's turn (interactor's move), read an integer , indicating they discarded a type card.
- If it is your turn, output an integer , indicating you discard a type card.
- If the game ends (both have one card left) and your score is suboptimal/your move is invalid, read
-1and exit. - If the game ends and your score is optimal, read
0and exit.
Note: After each output, flush the buffer. Common methods include:
- C++:
fflush(stdout)orcout.flush(). - C:
fflush(stdout). - Java:
System.out.flush(). - Python:
stdout.flush(). - Pascal:
flush(output). - Others: Refer to documentation.
Output Format
Follow the interaction rules described above.
2 2 0
1 0
1 1
1 1
1 1
2
0
1
2 2 0
2 3
3 4
1 1
1 1
2
0
1
2 3 1
1 -2
-1 2
1 2
2 1
1
2
0
1
2
Hint
Explanation
Sample #1
You play as Little R (first to act). If you discard a type card and the opponent discards type , your score is , which is optimal.
This sample satisfies Special Properties B and C.
Sample #2
As Little R, the optimal score is .
This sample satisfies Special Property A.
Sample #3
You play as Little M (second to act). The optimal score for Little M is .
Constraints
Bundled testing is used.
$$\def\arraystretch{1.5} \begin{array}{|c|c|c|c|c|c|}\hline \textbf{Subtask} & \textbf{Points} & \bm{n \leq} & \bm{m \leq} & \textbf{Special Property} & \textbf{Subtask Dependencies} \cr\hline 1 & 20 & 5 & 5 & - & - \cr\hline 2 & 15 & 10^3 & 10^4 & \mathbf{A} & - \cr\hline 3 & 20 & 10^3 & 10^4 & \mathbf{B} & - \cr\hline 4 & 20 & 10^3 & 10^3 & \mathbf{C} & - \cr\hline 5 & 25 & 10^3 & 10^4 & - & 1,2,3,4 \cr\hline \end{array}$$Special Properties:
- A: .
- B: contains only and .
- C: Each player initially has exactly one card per type.
For all data:
, , , , . The interactor's moves are guaranteed valid.
Translated by DeepSeek R1
京公网安备 11011102002149号