This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define a3 array<int, 3>
#define MP make_pair
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N = (1 << 20);
const int oo = 2e9;
unordered_map<ull, int> mem[N];
ull vl[N], ans = 0;
int m, n, a[N];
mt19937_64 rnd(chrono::system_clock().now().time_since_epoch().count());
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> m;
n = (1 << m);
if (m == 1){
cout << 2;
return 0;
}
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++){
int obr = ((n - 1) ^ i);
if (obr < i) continue;
vl[i] = rnd();
vl[obr] = ull(0) - vl[i];
}
mem[0][0]++;
ull sum = 0;
int xr = 0;
for (int i = 0; i < n; i++){
sum += vl[a[i]];
xr ^= a[i];
ans += mem[xr][sum];
mem[xr][sum]++;
}
cout << ull(n) * (ull(n) + 1) / 2 - ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |