# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
577727 | mosiashvililuka | Poklon (COCI17_poklon7) | C++14 | 402 ms | 118680 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;
const int N=4000009;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,cnt,lf[N],rg[N],f[N],dp[N],jm[N],msh[N],pas,p[N],pi;
void dfs(long long q, long long w){
msh[q]=w;
if(q>a){
dp[q]=1;
return;
}
dfs(lf[q],q);dfs(rg[q],q);
int qw=max(dp[lf[q]],dp[rg[q]]);
jm[lf[q]]=qw-dp[lf[q]];
jm[rg[q]]=qw-dp[rg[q]];
dp[q]=qw+1;
}
void dfs2(long long q){
jm[q]+=jm[msh[q]];
if(q>a) return;
dfs2(lf[q]);dfs2(rg[q]);
}
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a;cnt=a;
for(i=1; i<=a; i++){
cin>>c>>d;
if(c>0){
lf[i]=c;
}else{
cnt++;f[cnt]=-c;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |