QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#43076#3013. XOR SequencesdattranxxxWA 2ms3672kbC++873b2022-08-06 13:58:192022-08-06 13:58:20

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-06 13:58:20]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3672kb
  • [2022-08-06 13:58:19]
  • 提交

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