[语言月赛 202312] 异或构造题?

Luogu
IDLGB3908
Time1000ms
Memory512MB
DifficultyP1
2023O2优化位运算循环结构语言月赛
给定 $n$ 个非负整数 $a _ 1, a _ 2, \cdots, a _ n$,你需要确定一个非负整数 $x$,使得 $a _ 1 \oplus a _ 2 \oplus \cdots \oplus a _ n \oplus x$ 最小。 你需要计算 $x$ 和 $a _ 1 \oplus a _ 2 \oplus \cdots \oplus a _ n \oplus x$。 其中 $\oplus$ 代表异或,$x \oplus y$ 在 C++ 中可表示为 `x ^ y`。 对于两个非负整数 $x,y$,它们的**异或**是指,将它们作为二进制数,对二进制表示中的每一位进行如下运算得到的结果: - $x$ 和 $y$ 的这一位上不同时,结果的这一位为 $1$; - $x$ 和 $y$ 的这一位上相同时,结果的这一位为 $0$。 例如:$0\oplus 0=0$,$1\oplus 0=1$,$0\oplus 1=1$,$1\oplus 1=0$。 ## Input 输入共两行。 第一行一个整数 $n$,代表序列 $a$ 的长度。 第二行 $n$ 个整数 $a _ 1, a _ 2, \cdots, a _ n$,代表序列 $a$。 ## Output 输出共一行两个整数 $x$ 和 $a _ 1 \oplus a _ 2 \oplus \cdots \oplus a _ n \oplus x$。 [samples] ## Note ### 数据规模与约定 对于 $100\%$ 的数据,$1 \leq n \leq 10 ^ 6$,$0 \leq a _ i \leq 10 ^ {18}$。 | 测试点 | $n$ | $a _ i$ | 特殊性质 | | :-: | :-: | :-: | :-: | | $1$ | $= 1$ | $\leq 10 ^ 3$ | 无 | | $2$ | $= 2$ | $\leq 10 ^ 3$ | $a _ 1 = a _ 2$ | | $3 \sim 4$ | $= 2$ | $\leq 10 ^ 3$ | 无 | | $5$ | $\leq 10 ^ 3$ | $= 0$ | 无 | | $6 \sim 8$ | $\leq 10 ^ 3$ | $\leq 10 ^ 3$ | 无 | | $9 \sim 11$ | $\leq 10 ^ 6$ | $\leq 10 ^ 3$ | 无 | | $12 \sim 13$ | $\leq 10 ^ 6$ | $\leq 1$ | 无 | | $14 \sim 20$ | $\leq 10 ^ 6$ | $\leq 10 ^ {18}$ | 无 |
Samples
Input #1
2
1 2
Output #1
3 0
Input #2
2
7 7
Output #2
0 0
API Response (JSON)
{
  "problem": {
    "name": "[语言月赛 202312] 异或构造题?",
    "description": {
      "content": "给定 $n$ 个非负整数 $a _ 1, a _ 2, \\cdots, a _ n$,你需要确定一个非负整数 $x$,使得 $a _ 1 \\oplus a _ 2 \\oplus \\cdots \\oplus a _ n \\oplus x$ 最小。 你需要计算 $x$ 和 $a _ 1 \\oplus a _ 2 \\oplus \\cdots \\oplus a _ n \\oplus x$。 其中 $\\",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P1"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGB3908"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "给定 $n$ 个非负整数 $a _ 1, a _ 2, \\cdots, a _ n$,你需要确定一个非负整数 $x$,使得 $a _ 1 \\oplus a _ 2 \\oplus \\cdots \\oplus a _ n \\oplus x$ 最小。\n\n你需要计算 $x$ 和 $a _ 1 \\oplus a _ 2 \\oplus \\cdots \\oplus a _ n \\oplus x$。\n\n其中 $\\...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments