CF1673E.Power or XOR?

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The symbol ∧\wedge is quite ambiguous, especially when used without context. Sometimes it is used to denote a power (a∧b=aba\wedge b = a^b) and sometimes it is used to denote the XOR operation (a∧b=a⊕ba\wedge b=a\oplus b).

You have an ambiguous expression E=A1∧A2∧A3∧…∧AnE=A_1\wedge A_2\wedge A_3\wedge\ldots\wedge A_n. You can replace each ∧\wedge symbol with either a Power\texttt{Power} operation or a XOR\texttt{XOR} operation to get an unambiguous expression E′E'.

The value of this expression E′E' is determined according to the following rules:

  • All Power\texttt{Power} operations are performed before any XOR\texttt{XOR} operation. In other words, the Power\texttt{Power} operation takes precedence over XOR\texttt{XOR} operation. For example, 4  XOR  6  Power  2=4⊕(62)=4⊕36=324\;\texttt{XOR}\;6\;\texttt{Power}\;2=4\oplus (6^2)=4\oplus 36=32.
  • Consecutive powers are calculated from left to right. For example, 2  Power  3  Power  4=(23)4=84=40962\;\texttt{Power}\;3 \;\texttt{Power}\;4 = (2^3)^4 = 8^4 = 4096.

You are given an array BB of length nn and an integer kk. The array AA is given by Ai=2BiA_i=2^{B_i} and the expression EE is given by E=A1∧A2∧A3∧…∧AnE=A_1\wedge A_2\wedge A_3\wedge\ldots\wedge A_n. You need to find the XOR of the values of all possible unambiguous expressions E′E' which can be obtained from EE and has at least kk ∧\wedge symbols used as XOR\texttt{XOR} operation. Since the answer can be very large, you need to find it modulo 22202^{2^{20}}. Since this number can also be very large, you need to print its binary representation without leading zeroes. If the answer is equal to 00, print 00.

符号 ∧\wedge 具有高度歧义性,尤其在缺乏上下文时。有时它表示幂运算(a∧b=aba\wedge b = a^b),有时则表示按位异或(XOR)运算(a∧b=a⊕ba\wedge b=a\oplus b)。

你有一个歧义表达式 E=A1∧A2∧A3∧…∧AnE=A_1\wedge A_2\wedge A_3\wedge\ldots\wedge A_n。你可以将每个 ∧\wedge 符号替换为 Power\texttt{Power} 运算或 XOR\texttt{XOR} 运算,从而得到一个无歧义的表达式 E′E'。

该表达式 E′E' 的值由以下规则确定:

  • 所有 Power\texttt{Power} 运算均在任何 XOR\texttt{XOR} 运算之前执行。换言之,Power\texttt{Power} 运算的优先级高于 XOR\texttt{XOR} 运算。例如,4  XOR  6  Power  2=4⊕(62)=4⊕36=324\;\texttt{XOR}\;6\;\texttt{Power}\;2=4\oplus (6^2)=4\oplus 36=32。
  • 连续的幂运算是从左到右依次计算的。例如,2  Power  3  Power  4=(23)4=84=40962\;\texttt{Power}\;3 \;\texttt{Power}\;4 = (2^3)^4 = 8^4 = 4096。

给定一个长度为 nn 的数组 BB 和一个整数 kk。数组 AA 定义为 Ai=2BiA_i=2^{B_i},表达式 EE 定义为 E=A1∧A2∧A3∧…∧AnE=A_1\wedge A_2\wedge A_3\wedge\ldots\wedge A_n。你需要求出所有可能的无歧义表达式 E′E'(这些 E′E' 由 EE 得到,且其中至少有 kk 个 ∧\wedge 符号被用作 XOR\texttt{XOR} 运算)的值的异或和。由于答案可能非常大,你需要对 22202^{2^{20}} 取模。又因该模数本身也可能极大,你需输出其二进制表示(不含前导零)。若答案等于 00,则直接输出 00。

输入格式

The first line of input contains two integers nn and kk (1≤n≤220,0≤k<n)(1\leq n\leq 2^{20}, 0\leq k \lt n).

The second line of input contains nn integers B1,B2,…,BnB_1,B_2,\ldots,B_n (1≤Bi<220)(1\leq B_i \lt 2^{20}).

输入的第一行包含两个整数 nn 和 kk (1≤n≤220,0≤k<n)(1\leq n\leq 2^{20}, 0\leq k \lt n)。

输入的第二行包含 nn 个整数 B1,B2,…,BnB_1,B_2,\ldots,B_n (1≤Bi<220)(1\leq B_i \lt 2^{20})。

输出格式

Print a single line containing a binary string without leading zeroes denoting the answer to the problem. If the answer is equal to 00, print 00.

输出一行,包含一个不含前导零的二进制字符串,表示该问题的答案。如果答案等于 00,则输出 00。

输入输出样例

  • 输入#1

    3 2
    3 1 2

    输出#1

    1110
  • 输入#2

    3 1
    3 1 2

    输出#2

    1010010
  • 输入#3

    3 0
    3 1 2

    输出#3

    1000000000000000001010010
  • 输入#4

    2 1
    1 1

    输出#4

    0

说明/提示

For each of the testcases 11 to 33, A=23,21,22=8,2,4A = {2^3,2^1,2^2} = {8,2,4} and E=8∧2∧4E=8\wedge 2\wedge 4.

For the first testcase, there is only one possible valid unambiguous expression E′=8⊕2⊕4=14=(1110)2E' = 8\oplus 2\oplus 4 = 14 = (1110)_2.

For the second testcase, there are three possible valid unambiguous expressions E′E':

  • 8⊕2⊕4=148\oplus 2\oplus 4 = 14
  • 82⊕4=64⊕4=688^2\oplus 4 = 64\oplus 4= 68
  • 8⊕24=8⊕16=248\oplus 2^4 = 8\oplus 16= 24

XOR of the values of all of these is 14⊕68⊕24=82=(1010010)214\oplus 68\oplus 24 = 82 = (1010010)_2.

For the third testcase, there are four possible valid unambiguous expressions E′E':

  • 8⊕2⊕4=148\oplus 2\oplus 4 = 14
  • 82⊕4=64⊕4=688^2\oplus 4 = 64\oplus 4= 68
  • 8⊕24=8⊕16=248\oplus 2^4 = 8\oplus 16= 24
  • (82)4=644=224=16777216(8^2)^4 = 64^4 = 2^{24} = 16777216

XOR of the values of all of these is 14⊕68⊕24⊕16777216=16777298=(1000000000000000001010010)214\oplus 68\oplus 24\oplus 16777216 = 16777298 = (1000000000000000001010010)_2.

For the fourth testcase, A=2,2A={2,2} and E=2∧2E=2\wedge 2. The only possible valid unambiguous expression E′=2⊕2=0=(0)2E' = 2\oplus 2 = 0 = (0)_2.

对于测试用例 11 至 33,有 A={23,21,22}={8,2,4}A = \{2^3,2^1,2^2\} = \{8,2,4\},且 E=8∧2∧4E=8\wedge 2\wedge 4。

对于第一个测试用例,仅存在一种可能的有效无歧义表达式 E′=8⊕2⊕4=14=(1110)2E' = 8\oplus 2\oplus 4 = 14 = (1110)_2。

对于第二个测试用例,存在三种可能的有效无歧义表达式 E′E':

  • 8⊕2⊕4=148\oplus 2\oplus 4 = 14
  • 82⊕4=64⊕4=688^2\oplus 4 = 64\oplus 4= 68
  • 8⊕24=8⊕16=248\oplus 2^4 = 8\oplus 16= 24

所有这些值的异或结果为 14⊕68⊕24=82=(1010010)214\oplus 68\oplus 24 = 82 = (1010010)_2。

对于第三个测试用例,存在四种可能的有效无歧义表达式 E′E':

  • 8⊕2⊕4=148\oplus 2\oplus 4 = 14
  • 82⊕4=64⊕4=688^2\oplus 4 = 64\oplus 4= 68
  • 8⊕24=8⊕16=248\oplus 2^4 = 8\oplus 16= 24
  • (82)4=644=224=16777216(8^2)^4 = 64^4 = 2^{24} = 16777216

所有这些值的异或结果为 14⊕68⊕24⊕16777216=16777298=(1000000000000000001010010)214\oplus 68\oplus 24\oplus 16777216 = 16777298 = (1000000000000000001010010)_2。

对于第四个测试用例,A={2,2}A=\{2,2\},且 E=2∧2E=2\wedge 2。唯一可能的有效无歧义表达式为 E′=2⊕2=0=(0)2E' = 2\oplus 2 = 0 = (0)_2。

输入解题思路,AI测评打分。不知道怎么写?

首页