# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
952285 | Doncho_Bonboncho | Poklon (COCI17_poklon7) | C++14 | 191 ms | 64768 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |