[XJTUPC 2024] 循环移位

Luogu
IDLGP10524
Time2000ms
Memory256MB
DifficultyP6
2024O2优化高校校赛
给定长度为 $2^n$ 的数组 $a_i$ ($0 \leq i < 2^n$),你可以进行任意次循环移位。 求 $\sum_{i=0}^{2^n-1} a_i \oplus i$, $\sum_{i=0}^{2^n-1} a_i \& i$,$\sum_{i=0}^{2^n-1} a_i | i$ 的最大值。其中 $\oplus, \&, |$ 分别代表按位异或,按位与,按位或。 对于一个长度为 $m$ 的数组 $x_i$ ($0 \leq i < m$),其进行循环移位的结果 $x'_i$ 为: $$x'_i = \left\{ \begin{array}{ll} x_{i - 1} & i \neq 0 \\ x_{m - 1} & i = 0 \end{array}\right.$$ ## Input 输入第一行包含一个整数 $n$ ($1 \leq n \leq 20$),含义如题意所述。 接下来一行包含 $2^n$ 个整数 $a_i$ ($0 \leq a_i < 2^n$),为给定的数组。 ## Output 输出一行三个整数,由空格隔开,为 $\sum_{i=0}^{2^n-1} a_i \oplus i$,$\sum_{i=0}^{2^n-1} a_i \& i$,$\sum_{i=0}^{2^n-1} a_i | i$ 的最大值。 [samples]
Samples
Input #1
2
1 3 2 2
Output #1
8 5 11
Input #2
4
1 1 4 5 1 4 1 9 1 9 8 1 0 0 0 0
Output #2
149 41 157
API Response (JSON)
{
  "problem": {
    "name": "[XJTUPC 2024] 循环移位",
    "description": {
      "content": "给定长度为 $2^n$ 的数组 $a_i$ ($0 \\leq i < 2^n$),你可以进行任意次循环移位。 求 $\\sum_{i=0}^{2^n-1} a_i \\oplus i$, $\\sum_{i=0}^{2^n-1} a_i \\& i$,$\\sum_{i=0}^{2^n-1} a_i | i$ 的最大值。其中 $\\oplus, \\&, |$ 分别代表按位异或,按位与,按位或。 对于一个长",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": {
      "LuoguStyle": "P6"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP10524"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "给定长度为 $2^n$ 的数组 $a_i$ ($0 \\leq i < 2^n$),你可以进行任意次循环移位。\n\n求 $\\sum_{i=0}^{2^n-1} a_i \\oplus i$, $\\sum_{i=0}^{2^n-1} a_i \\& i$,$\\sum_{i=0}^{2^n-1} a_i | i$ 的最大值。其中 $\\oplus, \\&, |$ 分别代表按位异或,按位与,按位或。\n\n对于一个长...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments