#P10851. [EGOI 2024] Make Them Meet / 活动面基
[EGOI 2024] Make Them Meet / 活动面基
Background
Day 2 Problem D.
The statement is translated from EGOI2024 makethemmeet. The translation comes from ChatGPT and has been manually proofread. If there are any mistakes, please contact rui_er。
Warning: Abusing the judge for this problem will result in an account ban.
Problem Description
Mila and Laura have been friends online for a long time, but they have never met in real life. Now they are both attending the same live event, which means they will definitely meet. However, the hotel they are staying in is very large and complicated. So after several days, they still have not run into each other.
The hotel consists of rooms, numbered from to . Each room has a lamp whose color can be changed. You have found the hotel's electrical service room, which allows you to change the colors of the lamps. Your goal is to use these lamps to guide Mila and Laura so that they eventually meet.
The hotel can be represented as a graph with vertices (rooms) and edges (corridors connecting rooms). Mila and Laura initially start in two different rooms, but you do not know which rooms. You may perform several moves. Each move consists of printing a list of integers, meaning that the lamp in room becomes color , where . Then Mila and Laura will look at the color of the lamp in their current room, and walk to an adjacent room whose lamp has the same color. If there is no such adjacent room, they will stay where they are. If there are multiple such adjacent rooms, they will choose one arbitrarily.
If during your moves, Mila and Laura are in the same room, or they use the same corridor at the same time, then you have successfully made them meet. You may make at most moves, but if you use fewer moves, your score will be higher.
Note that you do not know which rooms Mila and Laura start in, and you also do not know how they will choose when they have multiple same-colored options. Your solution must be correct no matter what their starting rooms are, and no matter how they move.
Input Format
The first line contains two integers and , representing the number of rooms and the number of corridors.
The next lines each contain two integers and , indicating that rooms and are connected by a corridor.
Output Format
Output one line with an integer , the number of moves.
In the next lines, output integers each line, where for all we have . These lines represent your moves in chronological order.
3 2
0 1
1 2
5
2 2 2
2 2 3
2 2 3
1 2 2
1 2 2
Hint
Sample Explanation
In the sample, the graph is a path of length , so it could belong to test group , , or . If the room lamps are colored according to the sample output, then Mila and Laura will always meet.
For example, suppose Mila starts in room and Laura starts in room :
- Step 1: Mila must walk to room . If Laura walks to room , then they will meet on the corridor between and . Assume Laura walks to room .
- Step 2: Mila walks back to room , and Laura stays in room .
- Step 3: Mila walks to room again, and Laura stays in room .
- Step 4: Mila walks to room , and Laura walks to room . Then they will meet on the corridor between rooms and .
- Step 5: Mila and Laura swap positions and meet again (but this does not matter, because they have already met).
The figure below shows the first four steps of the sample.

Note that this is only the case where they start from rooms and . You can verify that no matter where they start and how they walk, the same sequence of moves guarantees that they meet.
Constraints
For all data, , , , and . It is guaranteed that every room is reachable from every other room, that there is no corridor connecting a room to itself, and that there are no multiple corridors connecting the same pair of rooms. You may use at most steps (i.e., ).
- Subtask 1 (at most points): , and the corridors are . That is, the graph is a star.
- Subtask 2 (at most points): , meaning there is a corridor between every pair of rooms. That is, the graph is complete.
- Subtask 3 (at most points): , and the corridors are . That is, the graph is a path.
- Subtask 4 (at most points): . That is, the graph is a tree.
- Subtask 5 (at most points): No additional constraints.
Note: Some test points were placed into multiple subtasks in EGOI. To save judging resources and reduce the workload of organizing the testdata, these test points are placed into the subtask with the smallest index among all subtasks that contain them. This may cause a solution to get a higher score than expected, but it still cannot pass the problem.
Scoring
For each subtask that your program solves correctly, you will receive a score according to the following formula:
$$\textrm{score}=\left\lfloor S_g\cdot\min\left(1,\frac{2000}{K_g+1900}+\frac{1}{5}\right)\right\rfloor$$Here is the full score of the subtask, and is the maximum number of steps used by your program among all test points in this subtask. This means that to get full score, you need to solve each test point in at most steps. The figure below shows the score as a function of .

Translated by ChatGPT 5