Submission #952285

# Submission time Handle Problem Language Result Execution time Memory
952285 2024-03-23T13:43:11 Z Doncho_Bonboncho Poklon (COCI17_poklon7) C++14
60 / 120
191 ms 64768 KB
#include <bits/stdc++.h>
using namespace std;

template< class T, class T2 > inline bool chkmin( T& a, const T2& b ){ return a > b ? a = b, 1 : 0; }
template< class T, class T2 > inline bool chkmax( T& a, const T2& b ){ return a < b ? a = b, 1 : 0; }

#ifndef LOCAL
#define cerr if( false )cerr
#endif

#define out(x) #x << " = " << x << "  "

typedef long long ll;

const int MAX_N = 1e6 + 42;
const ll mod = 1e9 + 7;

ll L[MAX_N];
ll R[MAX_N];

__int128 f( int curr ){

	cerr << " in " << out( curr ) << out( L[curr] ) << out( R[curr] ) << endl;
	__int128 lSum = -1 * L[curr];
	if( L[curr] > 0 ){
		lSum = f( L[curr] );
	}

	__int128 rSum = -1 * R[curr];
	if( R[curr] > 0 ){
		rSum = f( R[curr] );
	}

	//cerr << "out " << out( curr ) << out( lSum ) << out( rSum ) << endl;
	//cerr << out( std::max( lSum, rSum ) * 2 ) << endl;
	return std::max( lSum, rSum ) * 2;
}

int main (){

#ifndef LOCAL
	std::ios_base::sync_with_stdio( false ); std::cin.tie( NULL ); std::cout.tie( NULL );
#endif

	int n;
	std::cin >> n;
	for( int i=1 ; i <= n ; i++ ){
		std::cin >> L[i] >> R[i];
	}

	__int128 nas = f( 1 );
	//std::cout << f( 1 ) << endl;
	std::string s;
	while( nas ){
		s += ( nas & 1 ? "1" : "0" );
		nas >>= 1;
	}
	reverse( s.begin(), s.end() );
	std::cout << s << endl;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Incorrect 1 ms 2396 KB Output isn't correct
10 Correct 1 ms 2396 KB Output is correct
11 Incorrect 2 ms 2648 KB Output isn't correct
12 Incorrect 3 ms 2908 KB Output isn't correct
13 Incorrect 9 ms 6236 KB Output isn't correct
14 Incorrect 17 ms 9984 KB Output isn't correct
15 Correct 16 ms 8536 KB Output is correct
16 Incorrect 65 ms 20564 KB Output isn't correct
17 Incorrect 137 ms 36688 KB Output isn't correct
18 Incorrect 135 ms 38228 KB Output isn't correct
19 Incorrect 186 ms 39024 KB Output isn't correct
20 Incorrect 191 ms 64768 KB Output isn't correct