# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
545221 | AbdelmagedNour | Poklon (COCI17_poklon7) | C++17 | 255 ms | 56048 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>
#pragma GCC optimize("Ofast")
using namespace std;
const int N=1000005;
int n,L[N],R[N];
pair<int,int>res={0,0};
bool f(pair<int,int>a,pair<int,int>b){
if(a.first==0)return 0;
if(b.first==0)return 1;
if(a.first>b.first)return !f(b,a);
while(a.first<b.first&&a.second){
a.first*=2;
a.second--;
}
if(a.first>=b.first&&a.second>=b.second){
return 1;
}else return 0;
}
void dfs(int v,int dep=0){
if(v<=0){
pair<int,int>val={-v,dep};
if(f(val,res))res=val;
return;
}
dfs(L[v],dep+1);
dfs(R[v],dep+1);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)cin>>L[i]>>R[i];
dfs(1);
string s="";
while(res.first){
s+=char('0'+(res.first&1));
res.first/=2;
}
reverse(s.begin(),s.end());
cout<<s;
for(int i=0;i<res.second;i++)cout<<0;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |