QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#519134 | #8520. Xor Partitions | SocialPanda | WA | 1ms | 3852kb | C++23 | 744b | 2024-08-14 16:32:19 | 2024-08-14 16:32:20 |
Judging History
answer
#include <iostream>
#include <vector>
#define int long long
const int MOD = 1e9 + 7;
signed main() {
int n;
std::cin >> n;
std::vector<long long> a(n);
for (int i = 0; i < n; ++i) {
int num;
std::cin >> num;
a[i]=num%MOD;
}
std::vector<long long> xorSum(n + 1, 0);
std::vector<long long> dp(n + 1, 0);
dp[0] = 1; // Base case: one way to partition an empty sequence
for (int i = 1; i <= n; ++i) {
xorSum[i] = 0;
for (int j = i; j > 0; --j) {
xorSum[j] ^= a[i - 1];
dp[i] = (dp[i] + dp[j - 1] * xorSum[j]) % MOD;
}
}
std::cout << dp[n] << std::endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
4 7 3 1 2
output:
170
result:
ok 1 number(s): "170"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
1 0
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
1 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
3 1 2 3
output:
16
result:
ok 1 number(s): "16"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
4 0 1 0 1
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: -100
Wrong Answer
time: 1ms
memory: 3632kb
input:
562 918479109239293921 960173570446350728 374394588863436385 418106819278123099 473761712658352147 662782574081105364 824954323015093862 827581845536521847 184394794881199801 820907621998888642 606529830885621237 961790689782125501 582742201855597942 337901250755571075 287706594894797714 18578215893...
output:
95157266
result:
wrong answer 1st numbers differ - expected: '641941658', found: '95157266'