#P9316. [EGOI 2021] Double Move / 二选一游戏
[EGOI 2021] Double Move / 二选一游戏
Background
Day 2 Problem D.
The statement is translated from EGOI2021 doublemove.
Problem Description
Alice and Bob are playing a game, and Claire is helping them. There are stones, numbered from to . The game has three phases.
In the first phase, Alice and Bob take turns, with Alice going first. In each turn, a player announces which stone they are going to take, but they do not directly specify a single stone. Instead, they give two options. The two options may be the same. They may also mention stones that have already been mentioned before. No stones are taken in the first phase—the players only announce their intentions for the second phase. The first phase ends after announcements.
Here is an example of the first phase when :
- Alice: “I will take or .”
- Bob: “I will take or .”
- Alice: “I will take or .”
- Bob: “I will take or .”
In the second phase, for each of the announcements, Claire chooses one of the two options by saying “former” or “latter”. We call the sequence of Claire’s choices a plan. It can be seen that there are exactly possible plans. (Even if in some announcements the two options are exactly the same, we still consider choosing “former” and choosing “latter” as different plans.)
Here is one of the possible plans that Claire might choose:
- “Former”: Alice will take .
- “Former”: Bob will take .
- “Latter”: Alice will take .
- “Former”: Bob will take .
In the third phase, Alice and Bob start taking stones according to Claire’s choices. The first player who cannot perform their required move—because that stone has already been taken—loses the game. Note that there are stones and moves, so one player will inevitably lose in the end.
In the example above, Alice first takes . Bob then takes . Alice wants to take next, but it has already been taken, so Alice loses and Bob wins.
You are given the integer , and the game state at some moment during the first phase: a sequence of announcements that have already been made. These announcements may be completely arbitrary.
From this point on, Alice and Bob will play optimally, meaning:
No matter how Alice and Bob play, Claire chooses uniformly at random from the possible plans. Alice and Bob know this, so when they play optimally, each of them tries to minimize the number of plans in which they lose.
Assuming Alice and Bob continue the game as described above, compute, for each of them, the number of plans under which they win the game.
Input Format
The first line contains two integers : the number of stones and the number of announcements already made.
The next lines describe the announcements in order. Each line contains two integers: the indices of the two stones (in and not necessarily distinct).
Note that when , the player to make the next announcement is determined by the parity of .
Output Format
Print one line with two integers: the number of plans in which Alice wins, and the number of plans in which Bob wins, assuming both continue the game optimally as described above.
Note that the sum of these two integers should be .
3 4
1 3
2 2
3 2
1 3
4 12
2 0
4 4
Hint
Explanation for Sample .
This sample is the same as the one given in the Description. No further announcements need to be made, so we only need to count how many plans make Alice win and how many plans make Bob win. Alice wins if and only if Claire chooses in the first step, and chooses in the third step. All other plans make Alice lose.
Explanation for Sample .
If Alice first announces , Bob will announce . No matter what Alice announces next, she will lose, because Claire will choose in the first step and in the second step, and then there will be no remaining stone for Alice to take in the third step. However, this is not Alice’s optimal first move: she should instead announce first. Then, no matter how Bob and Alice announce in the last two steps, they will each win out of the plans.
Constraints
For all data, , .
- Subtask 1 ( points): .
- Subtask 2 ( points): .
- Subtask 3 ( points): .
- Subtask 4 ( points): .
- Subtask 5 ( points): no additional constraints.
Translated by ChatGPT 5