CSES - Datatähti 2018 peili - Results
Submission details
Task:Bittijono
Sender:367535629127093
Submission time:2017-10-09 19:54:13 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'unsigned int subsqcnt(unsigned int)':
input/code.cpp:8:15: warning: unused variable 'ff' [-Wunused-variable]
  unsigned int ff;
               ^
input/code.cpp: In function 'int main()':
input/code.cpp:39:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<n; i++) {
                 ^
input/code.cpp:58:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(uniqsubBIT(bst, bp)-1<n) {
                              ^
input/code.cpp:65:3: error: 'POISTAMUTHETINYT' was not declared in this scope
   POISTAMUTHETINYT++;
   ^
input/code.cpp:66:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(nnnnnn-1 == n) {
                  ^
input/code.cpp:70:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(nnnnnn*2<n) { /// ei kai toimi
               ^

Code

#include <bits/stdc++.h>

using namespace std;

unsigned int n;

inline unsigned int subsqcnt(unsigned int asd) {
	unsigned int ff;
	if(asd==0)
		return 1;
	else if(asd==1)
		return 2;
	else 
		return subsqcnt(asd-2) + subsqcnt(asd-1) + 1;
}
inline int uniqsubBIT(bitset<32> bs, int length) {
	bs = bs.flip();
	int yk = 1;
	int nl = 0;
	int count = 2;
	int prev;
	for(int i=length-2; i>=0; i--) {
		prev = count;
		count *= 2;
		if(bs[i]==false) {
			count -= nl;
			nl = prev;
		} else {
			count -= yk;
			yk = prev;
		}
	}
	return count;
}

int main() {
	cin >> n;
	int bp = 1;
	for(int i=0; i<n; i++) {
		bp = i;
		if(subsqcnt(i)-1>=n)
			break;
	}
	string cur;
	einain:
	int ff = pow(2, bp)/1.5;
	for(int i=pow(2, bp)/10; i<ff; i++) {
		if(__builtin_popcount(i)==1&&i>2){
		herranpieksut:
				int fhj = i;
				int huhu=1;
				while(fhj>=2) {
					fhj/=2;
					huhu++;
				}
				int verytemp =(4*pow(2,huhu)-3-(-pow(-1,huhu)))/6+1;
				bitset<32> bst(verytemp);
				if(uniqsubBIT(bst, bp)-1<n) {
					i = pow(2, huhu);
					continue;
				}
			}
		bitset<32> bs(i);
		int nnnnnn = uniqsubBIT(bs, bp);
		POISTAMUTHETINYT++;
		if(nnnnnn-1 == n) {
			cout << bs.to_string().substr(32-bp);
			return 0;
		}
		if(nnnnnn*2<n) { /// ei kai toimi
			i++;
			if(__builtin_popcount(i)==1&&i>2)	
				goto herranpieksut;
		}
	}
	bp++;
	goto einain;
}