QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#519146#8520. Xor PartitionsSocialPandaWA 5ms10552kbPython3619b2024-08-14 16:39:062024-08-14 16:39:07

Judging History

你现在查看的是最新测评结果

  • [2024-08-14 16:39:07]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:10552kb
  • [2024-08-14 16:39:06]
  • 提交

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'