QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#56094#3013. XOR SequencesYaoBIG#WA 1ms3560kbC++797b2022-10-16 22:39:132022-10-16 22:39:15

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-16 22:39:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3560kb
  • [2022-10-16 22:39:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	int h = 1 << n;

	vector<int> cs(h);
	for (int& c : cs) cin >> c;

	vector<pair<int, int>> itv(m);
	for (int i = 0; i < m; ++i) itv[i] = {h, -1};
	for (int i = 0; i < h; ++i) {
		int v = cs[i] - 1;
		itv[v].first = min(itv[v].first, i);
		itv[v].second = max(itv[v].second, i);
	}
	sort(itv.begin(), itv.end());

	ll res = 1;
	int lst = -1;
	for (int i = 0; i < m; ++i) {
		int a = itv[i].first;
		int b = itv[i].second;
		if (lst >= a) res = 0;
		lst = b;

		int len = b - a + 1;
		if (__builtin_popcount(len) > 1) res = 0;
		if (a % len != 0) res = 0;

		res = (res * len) % MOD;
	}
	cout << res << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3560kb

input:

4 12
2
2
3
6
1
12
1
12
9
7
5
5
4
8
10
11

output:

0

result:

wrong answer expected 8, found 0