Submission #485278

# Submission time Handle Problem Language Result Execution time Memory
485278 2021-11-07T00:39:35 Z errorgorn Dojave (COCI17_dojave) C++17
28 / 140
88 ms 11060 KB
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << ": " << x << endl

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define ub upper_bound

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
int arr[1100000];
bool cnt[1100000];
bool f[1100000];

vector<int> v;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	
	cin>>n;
	rep(x,0,1<<n) cin>>arr[x];
	
	int af=(1<<n)-1;
	
	rep(x,0,1<<n){
		if (!cnt[arr[x]]){
			f[x]=true;
			cnt[af^arr[x]]=true;
		}
	}
	
	v.pub(0);
	
	int num=0;
	rep(x,1,(1<<n)+1){
		if (f[x-1]) num++;
		if (x%2==0 && x/2==num) v.pub(x/2);
	}
	
	ll odd=0,even=0;
	for (auto &it:v){
		if (it%2==0) even++;
		else odd++;
	}
	
	cout<<((1LL<<n)*((1LL<<n)+1)-odd*(odd-1)-even*(even-1))/2;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Incorrect 0 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
3 Correct 2 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1100 KB Output is correct
2 Incorrect 5 ms 972 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1100 KB Output is correct
2 Incorrect 15 ms 1324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2292 KB Output is correct
2 Incorrect 20 ms 1920 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 86 ms 6880 KB Output is correct
2 Correct 88 ms 6848 KB Output is correct
3 Correct 83 ms 11060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 6804 KB Output is correct
2 Incorrect 77 ms 5828 KB Output isn't correct
3 Halted 0 ms 0 KB -