CF1673E.Power or XOR?
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The symbol ∧ is quite ambiguous, especially when used without context. Sometimes it is used to denote a power (a∧b=ab) and sometimes it is used to denote the XOR operation (a∧b=a⊕b).
You have an ambiguous expression E=A1∧A2∧A3∧…∧An. You can replace each ∧ symbol with either a Power operation or a XOR operation to get an unambiguous expression E′.
The value of this expression E′ is determined according to the following rules:
- All Power operations are performed before any XOR operation. In other words, the Power operation takes precedence over XOR operation. For example, 4XOR6Power2=4⊕(62)=4⊕36=32.
- Consecutive powers are calculated from left to right. For example, 2Power3Power4=(23)4=84=4096.
You are given an array B of length n and an integer k. The array A is given by Ai=2Bi and the expression E is given by E=A1∧A2∧A3∧…∧An. You need to find the XOR of the values of all possible unambiguous expressions E′ which can be obtained from E and has at least k ∧ symbols used as XOR operation. Since the answer can be very large, you need to find it modulo 2220. Since this number can also be very large, you need to print its binary representation without leading zeroes. If the answer is equal to 0, print 0.
符号 ∧ 具有高度歧义性,尤其在缺乏上下文时。有时它表示幂运算(a∧b=ab),有时则表示按位异或(XOR)运算(a∧b=a⊕b)。
你有一个歧义表达式 E=A1∧A2∧A3∧…∧An。你可以将每个 ∧ 符号替换为 Power 运算或 XOR 运算,从而得到一个无歧义的表达式 E′。
该表达式 E′ 的值由以下规则确定:
- 所有 Power 运算均在任何 XOR 运算之前执行。换言之,Power 运算的优先级高于 XOR 运算。例如,4XOR6Power2=4⊕(62)=4⊕36=32。
- 连续的幂运算是从左到右依次计算的。例如,2Power3Power4=(23)4=84=4096。
给定一个长度为 n 的数组 B 和一个整数 k。数组 A 定义为 Ai=2Bi,表达式 E 定义为 E=A1∧A2∧A3∧…∧An。你需要求出所有可能的无歧义表达式 E′(这些 E′ 由 E 得到,且其中至少有 k 个 ∧ 符号被用作 XOR 运算)的值的异或和。由于答案可能非常大,你需要对 2220 取模。又因该模数本身也可能极大,你需输出其二进制表示(不含前导零)。若答案等于 0,则直接输出 0。
输入格式
The first line of input contains two integers n and k (1≤n≤220,0≤k<n).
The second line of input contains n integers B1,B2,…,Bn (1≤Bi<220).
输入的第一行包含两个整数 n 和 k (1≤n≤220,0≤k<n)。
输入的第二行包含 n 个整数 B1,B2,…,Bn (1≤Bi<220)。
输出格式
Print a single line containing a binary string without leading zeroes denoting the answer to the problem. If the answer is equal to 0, print 0.
输出一行,包含一个不含前导零的二进制字符串,表示该问题的答案。如果答案等于 0,则输出 0。
输入输出样例
输入#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 1 to 3, A=23,21,22=8,2,4 and E=8∧2∧4.
For the first testcase, there is only one possible valid unambiguous expression E′=8⊕2⊕4=14=(1110)2.
For the second testcase, there are three possible valid unambiguous expressions E′:
- 8⊕2⊕4=14
- 82⊕4=64⊕4=68
- 8⊕24=8⊕16=24
XOR of the values of all of these is 14⊕68⊕24=82=(1010010)2.
For the third testcase, there are four possible valid unambiguous expressions E′:
- 8⊕2⊕4=14
- 82⊕4=64⊕4=68
- 8⊕24=8⊕16=24
- (82)4=644=224=16777216
XOR of the values of all of these is 14⊕68⊕24⊕16777216=16777298=(1000000000000000001010010)2.
For the fourth testcase, A=2,2 and E=2∧2. The only possible valid unambiguous expression E′=2⊕2=0=(0)2.
对于测试用例 1 至 3,有 A={23,21,22}={8,2,4},且 E=8∧2∧4。
对于第一个测试用例,仅存在一种可能的有效无歧义表达式 E′=8⊕2⊕4=14=(1110)2。
对于第二个测试用例,存在三种可能的有效无歧义表达式 E′:
- 8⊕2⊕4=14
- 82⊕4=64⊕4=68
- 8⊕24=8⊕16=24
所有这些值的异或结果为 14⊕68⊕24=82=(1010010)2。
对于第三个测试用例,存在四种可能的有效无歧义表达式 E′:
- 8⊕2⊕4=14
- 82⊕4=64⊕4=68
- 8⊕24=8⊕16=24
- (82)4=644=224=16777216
所有这些值的异或结果为 14⊕68⊕24⊕16777216=16777298=(1000000000000000001010010)2。
对于第四个测试用例,A={2,2},且 E=2∧2。唯一可能的有效无歧义表达式为 E′=2⊕2=0=(0)2。
输入解题思路,AI测评打分。不知道怎么写?