CSES - Datatähti 2019 loppu - Results
Submission details
Task:Binääripuu
Sender:Santeri Toivonen
Submission time:2019-01-17 15:00:45 +0200
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'void hmm(long long int)':
input/code.cpp:29:3: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   while(bb<(1<<(n-1)))
   ^~~~~
input/code.cpp:31:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
     if((aa-((ll)1<<(n-1))) < ((ll)1<<n-1)/2) {
     ^~
input/code.cpp:31:39: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
     if((aa-((ll)1<<(n-1))) < ((ll)1<<n-1)/2) {
                                      ~^~
input/code.cpp: In function 'int main()':
input/code.cpp:83:3: error: 'k' was not declared in this scope
   k[f] = 1;
   ^
input/code.cpp:85:2: error: 'd' was not declared in this scope
  d[1] = 1;
  ^
input/code.cpp:89:7: error: 'k' was not declared in this scope
   if(!k[i])
       ^
input/code.cpp:92:30: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
     if((i-(1<<(n-1))) < (1<<n-1)/2) {
                             ~^~

Code

#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define N (1<<18)
#define M 1000000007

using namespace std;

ll n, m, f;
ll aaa, bbb;
set<ll> kiel;

bool hae(ll kohta) {
		kohta /= 2;
		while(kohta>=1) {
				if(kiel.find(kohta) != kiel.end())
						return true;
				kohta /=2;
		}
		return false;
}

void hmm(ll kohta) {
		ll aa = kohta;
		ll bb = kohta;
		while(aa<(1<<(n-1)))
				aa = aa*2;
		while(bb<(1<<(n-1)))
				bb = bb*2+1;
				if((aa-((ll)1<<(n-1))) < ((ll)1<<n-1)/2) {
				aaa+=bb-aa+1;
				}else
				bbb+=bb-aa+1;
		aaa %= M;
		bbb %= M;
}

int main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	if(1 == 1)  { //////////////////////////////////////////
		ll ans = 4;
		for(int i=3; i<n; i++) {
		ans *= 2;
		ans%=M;
		}
		for(int i=0; i<m; i++) {
				cin >> f;
				kiel.insert(f);
		}
		vector<ll> ei;
		for(auto u:kiel) {
				if(hae(u))
						ei.push_back(u);
		}
		for(auto u:ei)
				kiel.erase(u);
		for(auto u:kiel)
		hmm(u);
		aaa %= M;
		bbb %= M;
		aaa = (((ll)1<<(n-2))%M-aaa)%M;
		bbb = (((ll)1<<(n-2))%M-bbb)%M;
		cout << abs((aaa*bbb*2))%M;
		exit(0);
	}
	if(n>6) {
		if(m)
			exit(0);
		ll ans = 8;
		for(int i=3; i<n; i++) {
		ans *= 4;
		ans%=M;
		}
		cout << ans;
		exit(0);
	}
	for(int i=0; i<m; i++) {
		cin >> f;
		k[f] = 1;
	}
	d[1] = 1;
	int a = 0;
	int b = 0;
	for(int i=2; i<(1<<n); i++) {
		if(!k[i])
			d[i] = d[i/2];
		if(i>=(1<<(n-1))) {
				if((i-(1<<(n-1))) < (1<<n-1)/2) {
				a+=d[i];
				}else
				b+=d[i];
		}
	}
/*	for(int i=(1<<(n-1))-1; i>=2; i--) {
		d[i] = d[i*2]+d[i*2+1];
//		if(k[i])
	//		d[i] = 0;
	}*/
	cout << a*b*2;
}