#P6365. [传智杯 #2 初赛] 众数出现的次数
[传智杯 #2 初赛] 众数出现的次数
Description
In the class of ChuanZhi training students, to liven up the atmosphere and reinforce knowledge of bitwise operations, the students play a game.
There are students in the class. Each student receives two cards, a red card and a black card. Each card has a non-negative integer not exceeding . For student , the number on the red card is , and the number on the black card is .
Now each student needs to play a number. Each student may either play the number on their red card directly, or play the result of applying bitwise XOR to their red-card number and their black-card number. In the end, the teacher collects all numbers played by the students.
Among these numbers, the one that appears the most times is the mode. Under the optimal cooperative strategy of all students, we want the number of occurrences of the mode to be as large as possible. What is the number that appears the most times?
Input Format
The first line contains a positive integer .
The next lines follow. On line , two non-negative integers represent the numbers on the red card and the black card of student .
Output Format
Output one integer, representing the answer. If there are multiple solutions, output the smallest one.
4
21 9
28 9
28 3
17 4
21
Hint
Explanation of the sample:
The maximum number of occurrences of a mode is . There are two ways:
- Student plays the red card directly, student plays the XOR of red and black, student plays either one, and student plays the XOR of red and black. Then students can all play .
- Student plays the XOR of red and black, student plays the red card directly, student plays the red card directly, and student plays either one. Then students can all play .
So both and are modes with the maximum number of occurrences, because at most it can occur times, and there is no plan that makes it occur times. But since the problem requires that if there are multiple solutions we output the smaller one, we should output .
Translated by ChatGPT 5
京公网安备 11011102002149号