Submission #485282

# Submission time Handle Problem Language Result Execution time Memory
485282 2021-11-07T00:54:44 Z errorgorn Dojave (COCI17_dojave) C++17
42 / 140
109 ms 6596 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];
	
	if (n==1){
		cout<<2<<endl;
		return 0;
	}
	
	int af=(1<<n)-1;
	
	rep(x,0,1<<n){
		if (!cnt[arr[x]]){
			f[x]=true;
			cnt[af^arr[x]]=true;
		}
	}
	
	ll r0=1,r1=1,r2=0,r3=0;
	
	int num=0;
	rep(x,1,(1<<n)+1){
		if (f[x-1]) num++;
		if (x%2==0 && x/2==num){
			if (x%4==0) r0++;
			else r2++;
		}
	}
	
	rep(x,0,1<<n) if ((arr[x]^af)==arr[0]) f[x]=1;
	
	num=0;
	rep(x,1,(1<<n)){
		if (f[x]) num++;
		if (x%2==0 && x/2==num){
			if (x%4==0) r1++;
			else r3++;
		}
	}
	
	ll ans=(1LL<<n)*((1LL<<n)+1);
	ans-=r0*(r0-1);
	ans-=r1*(r1-1);
	ans-=r2*(r2-1);
	ans-=r3*(r3-1);
	cout<<(ans)/2;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# 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 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 716 KB Output is correct
2 Incorrect 6 ms 588 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 716 KB Output is correct
2 Incorrect 11 ms 972 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 1860 KB Output is correct
2 Incorrect 34 ms 1544 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 88 ms 6428 KB Output is correct
2 Correct 108 ms 6456 KB Output is correct
3 Correct 109 ms 6596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 6440 KB Output is correct
2 Incorrect 83 ms 5424 KB Output isn't correct
3 Halted 0 ms 0 KB -