Submission #42337

#TimeUsernameProblemLanguageResultExecution timeMemory
42337milmillinPoklon (COCI17_poklon7)C++14
48 / 120
337 ms120396 KiB
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

long long l[1000100];
long long r[1000100];

long long getWgt(int idx) {
	if (idx<0) return -idx;
	return max(getWgt(l[idx]),getWgt(r[idx]))*2;
}

int main () {
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%lld%lld",&l[i],&r[i]);
	}
	long long ans=getWgt(1);
	//printf("%lld\n",ans);
	string x;
	while (ans) {
		if (ans%2) x.push_back('1');
		else x.push_back('0');
		ans/=2;
	}
	reverse(x.begin(),x.end());
	cout << x << '\n';
	return 0;
}

Compilation message (stderr)

poklon.cpp: In function 'int main()':
poklon.cpp:18:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
poklon.cpp:20:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld",&l[i],&r[i]);
                                ^
#Verdict Execution timeMemoryGrader output
Fetching results...