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