QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#43076 | #3013. XOR Sequences | dattranxxx | WA | 2ms | 3672kb | C++ | 873b | 2022-08-06 13:58:19 | 2022-08-06 13:58:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 20, M = 1e9 + 7;
int mul(ll x, ll y) {
return x * y % M;
}
int m, n;
int a[1 << N], pos[1 << N];
int call(int bit, int l) {
if (bit == 0)
return 1;
int r = l + (1 << bit) - 1;
int m = l + (1 << (bit - 1)) - 1;
for (int i = l; i <= r; ++i)
pos[a[i]] = -1;
int flag = 0;
for (int i = l; i <= m; ++i)
pos[a[i]] = i;
for (int i = m+1; i <= r; ++i)
if (pos[a[i]] != -1) flag = 1;
if (!flag) return mul(call(bit - 1, l), call(bit - 1, m+1));
for (int i = m+1; i <= r; ++i)
if (pos[a[i]] + (1 << (bit - 1)) != i) return 0;
return mul(call(bit - 1, l), 2);
}
int main() {
cin.tie(0)->sync_with_stdio(0); cout.tie(0);
cin >> m >> n;
for (int i = 0; i < 1 << m; ++i)
cin >> a[i];
cout << call(m, 0);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3616kb
input:
4 12 2 2 3 6 1 12 1 12 9 7 5 5 4 8 10 11
output:
8
result:
ok answer is 8
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3672kb
input:
4 5 2 2 2 2 5 1 5 1 4 4 3 3 4 4 3 3
output:
0
result:
wrong answer expected 64, found 0