# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
315399 | Ahmad_Hasan | Poklon (COCI17_poklon7) | C++17 | 1088 ms | 20984 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |