Submission #42337

# Submission time Handle Problem Language Result Execution time Memory
42337 2018-02-26T08:46:55 Z milmillin Poklon (COCI17_poklon7) C++14
48 / 120
337 ms 120396 KB
#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

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 time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 464 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 1 ms 476 KB Output is correct
5 Correct 1 ms 584 KB Output is correct
6 Correct 1 ms 692 KB Output is correct
7 Correct 1 ms 696 KB Output is correct
8 Correct 2 ms 816 KB Output is correct
9 Incorrect 1 ms 816 KB Output isn't correct
10 Incorrect 2 ms 816 KB Output isn't correct
11 Incorrect 5 ms 1172 KB Output isn't correct
12 Incorrect 5 ms 1384 KB Output isn't correct
13 Incorrect 17 ms 3528 KB Output isn't correct
14 Incorrect 33 ms 6692 KB Output isn't correct
15 Incorrect 33 ms 6796 KB Output isn't correct
16 Incorrect 110 ms 20208 KB Output isn't correct
17 Incorrect 307 ms 45316 KB Output isn't correct
18 Incorrect 261 ms 60456 KB Output isn't correct
19 Incorrect 337 ms 77200 KB Output isn't correct
20 Incorrect 313 ms 120396 KB Output isn't correct