#P12290. Gene XOR Combination Game
Gene XOR Combination Game
Gene XOR Combination Game
In the field of medicine, two distinguished doctors, XiaoLan and XiaoQiao, are researching a new type of gene therapy. They have n candidate genes, represented by an array \(\{a_1,a_2,\cdots,a_n\}\) where each \(a_i\) denotes the characteristic value of the i-th gene. They plan to combine two genes (each doctor picks one gene) by applying the bitwise XOR operation (denoted as \(\oplus\)).
XiaoLan is inclined toward aggressive treatments and wants the resulting XOR value to be as large as possible. In contrast, XiaoQiao prefers a more stable treatment and wishes the XOR value to be as small as possible.
Both are assumed to be very clever and will use optimal strategies according to their objectives. Two scenarios are considered:
- Scenario 1 (XiaoLan goes first): XiaoLan picks a gene first. Then, XiaoQiao picks a different gene, aiming to minimize the resulting \(x \oplus y\) value. Knowing that XiaoQiao will choose his gene to minimize the outcome, XiaoLan will choose his gene to maximize the value of \(\min_{y\neq x}(x \oplus y)\). The resulting value in this scenario is \[ \max_{x\in \{a_1,\cdots,a_n\}} \; \min_{y\in \{a_1,\cdots,a_n\}\setminus\{x\}} (x\oplus y). \]
- Scenario 2 (XiaoQiao goes first): XiaoQiao picks a gene first. Then, XiaoLan picks a different gene to maximize \(x \oplus y\). Knowing that XiaoLan will choose his gene optimally, XiaoQiao will choose his gene so that even after XiaoLan's choice the outcome \(\max_{y\neq x}(x \oplus y)\) is as small as possible. The resulting value in this scenario is \[ \min_{x\in \{a_1,\cdots,a_n\}} \; \max_{y\in \{a_1,\cdots,a_n\}\setminus\{x\}} (x\oplus y). \]
Given the list of candidate genes, determine the outcome value for both scenarios.
inputFormat
The first line contains an integer \(n\) (\(n\ge2\)), the number of candidate genes. The second line contains \(n\) space-separated non-negative integers \(a_1,a_2,\ldots,a_n\) representing the candidate genes.
outputFormat
Output two integers separated by a space. The first integer is the resulting XOR value if XiaoLan (the aggressive doctor) goes first, i.e. \(\max_{x}\;\min_{y\neq x}(x\oplus y)\). The second integer is the resulting XOR value if XiaoQiao goes first, i.e. \(\min_{x}\;\max_{y\neq x}(x\oplus y)\).
sample
2
1 2
3 3