# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89373 | vex | Poklon (COCI17_poklon7) | C++14 | 291 ms | 39740 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>
#define maxn 1000005
using namespace std;
int n;
int l[maxn];
int r[maxn];
long long resi(int x)
{
long long sol;
if(l[x]>0)sol=resi(l[x]);else sol=-l[x];
if(r[x]>0)sol=max(sol,resi(r[x]));else sol=max(sol,(long long)(-r[x]));
return 2*sol;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>l[i]>>r[i];
}
long long sol=resi(1);
string s;
while(sol>0)
{
s.push_back(sol%2 + '0');
sol/=2;
}
int len=s.size();
for(int i=len-1;i>=0;i--)cout<<s[i];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |