QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#519146 | #8520. Xor Partitions | SocialPanda | WA | 5ms | 10552kb | Python3 | 619b | 2024-08-14 16:39:06 | 2024-08-14 16:39:07 |
Judging History
answer
MOD = 10**9 + 7
def calculate_partition_sum(n, a):
prefix_xor = 0
dp = [0] * (n + 1)
dp[0] = 1
xor_count = {0: 1} # 初始状态
for i in range(1, n + 1):
prefix_xor ^= a[i - 1]
dp[i] = dp[i - 1]
if prefix_xor in xor_count:
dp[i] = (dp[i] + xor_count[prefix_xor]) % MOD
xor_count[prefix_xor] = (xor_count.get(prefix_xor, 0) + dp[i - 1]) % MOD
return dp[n]
# 读取输入
n = int(input().strip())
a = list(map(int, input().strip().split()))
# 计算并输出结果
result = calculate_partition_sum(n, a)
print(result)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 10552kb
input:
4 7 3 1 2
output:
2
result:
wrong answer 1st numbers differ - expected: '170', found: '2'