# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
315399 | Ahmad_Hasan | Poklon (COCI17_poklon7) | C++17 | 1088 ms | 20984 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;
vector<pair<int,int> >vps;
int cntdpth=1;
int ans=0;
int trg;
int slvmx(int cr=0,int dpth=1){
cntdpth=max(cntdpth,dpth);
int mx=-1;
if(vps[cr].first<0){
mx=max(mx,vps[cr].first*-1);
}else{
mx=max(mx,slvmx(vps[cr].first-1,dpth+1)*2);
}
if(vps[cr].second<0){
mx=max(mx,vps[cr].second*-1);
}else{
mx=max(mx,slvmx(vps[cr].second-1,dpth+1)*2);
}
return mx;
}
int main()
{
int n;
cin>>n;
vps=vector<pair<int,int> >(n);
for(int i=0;i<n;i++){
int x,y;
cin>>x>>y;
vps[i]={x,y};
}
trg=2*slvmx();
trg+=(trg%(1<<cntdpth)==0)?0:((1<<cntdpth)-(trg%cntdpth));
string binary = std::bitset<64>(trg).to_string();
binary.erase(0, binary.find_first_not_of('0'));
cout << binary;
return 0;
}
/***
3 5 4
1 2 4 2 1
3 5 1 2 4
1 5 7 1 2
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |