#include <bits/stdc++.h>
using namespace std;
#define dbg(x) cerr << #x << ": " << x << endl;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int m;
cin >> m;
const int n = 1 << m;
int max_mask = n - 1;
vector<int> s(n);
vector<uint64_t> xor_hash(n);
mt19937_64 rng(123);
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
if (x & (1 << (m - 1))) x ^= max_mask;
s[i] = x;
xor_hash[i] = rng();
}
long long ans = 1LL * n * (n + 1) / 2;
vector<unordered_map<uint64_t, int>> pos(4);
++pos[3][0];
uint64_t pref = 0;
for (int i = 0; i < n; ++i) {
pref ^= xor_hash[s[i]];
ans -= pos[i % 4][pref];
++pos[i % 4][pref];
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
456 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
596 KB |
Output is correct |
2 |
Correct |
2 ms |
780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1236 KB |
Output is correct |
2 |
Correct |
4 ms |
980 KB |
Output is correct |
3 |
Correct |
4 ms |
844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
4172 KB |
Output is correct |
2 |
Correct |
16 ms |
3396 KB |
Output is correct |
3 |
Correct |
37 ms |
6612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
4180 KB |
Output is correct |
2 |
Correct |
34 ms |
6696 KB |
Output is correct |
3 |
Correct |
87 ms |
14856 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
109 ms |
15944 KB |
Output is correct |
2 |
Correct |
71 ms |
13248 KB |
Output is correct |
3 |
Correct |
85 ms |
13396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
682 ms |
63692 KB |
Output is correct |
2 |
Correct |
642 ms |
63528 KB |
Output is correct |
3 |
Correct |
290 ms |
41604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
677 ms |
63668 KB |
Output is correct |
2 |
Correct |
473 ms |
52524 KB |
Output is correct |
3 |
Correct |
576 ms |
55508 KB |
Output is correct |
4 |
Correct |
672 ms |
63636 KB |
Output is correct |