QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#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;
}
Details
Tip: Click on the bar to expand more detailed information
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