#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 1005000
#define M ll(1e9 + 7)
#define inf 1e9 + 1e9
using namespace std;
//using namespace __gnu_pbds;
typedef long double ld;
typedef long long ll;
typedef short int si;
typedef array <int, 2> a2;
//typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int mk[N];
ll val[N];
unordered_map <int, unordered_map <int, int> > mp;
int main()
{
//freopen("input.txt", "r", stdin); //freopen("output4.txt", "w", stdout);
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
srand(time(0));
ll n;
cin >> n;
if (n == 1) {cout << 2 << endl; exit(0);}
n = (1 << n);
ll a[n], ans = 0;
for (ll i = 0; i < n; i++) cin >> a[i];
for (ll i = 0; i < n; i++)
{
ll vl = (n - 1) ^ i;
val[i] = rand();
val[vl] = -val[i];
}
mp[0][0]++;
ll sum = 0, xr = 0;
for (ll i = 0; i < n; i++)
{
sum += val[a[i]];
xr ^= a[i];
ans += mp[sum][xr];
mp[sum][xr]++;
}
cout << (n * (n + 1)) / 2 - ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
768 KB |
Output is correct |
2 |
Correct |
7 ms |
1024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
1208 KB |
Output is correct |
2 |
Correct |
11 ms |
1664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
3200 KB |
Output is correct |
2 |
Correct |
11 ms |
2048 KB |
Output is correct |
3 |
Correct |
10 ms |
1920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
57 ms |
11784 KB |
Output is correct |
2 |
Correct |
31 ms |
7336 KB |
Output is correct |
3 |
Correct |
87 ms |
16392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
11912 KB |
Output is correct |
2 |
Correct |
80 ms |
14344 KB |
Output is correct |
3 |
Correct |
191 ms |
37944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
276 ms |
46600 KB |
Output is correct |
2 |
Correct |
176 ms |
28424 KB |
Output is correct |
3 |
Correct |
187 ms |
34108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1255 ms |
185960 KB |
Output is correct |
2 |
Correct |
1183 ms |
186068 KB |
Output is correct |
3 |
Correct |
633 ms |
104868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1260 ms |
186028 KB |
Output is correct |
2 |
Incorrect |
756 ms |
113004 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |