Submission #89373

#TimeUsernameProblemLanguageResultExecution timeMemory
89373vexPoklon (COCI17_poklon7)C++14
48 / 120
291 ms39740 KiB
#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 timeMemoryGrader output
Fetching results...