184312025-10-22 16:37:51KristófBináris fa magassága (50 pont)cpp17Wrong answer 0/50109ms748 KiB
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;


void modify(vector<int> &fa,int n)
{
fa[n]=max(fa[n*2],fa[n*2+1])+1;
}

void redo(vector<int> &fa,int n,int x)
{
fa[n]=x;

while(n!=1)
    {
    n/=2;
    modify(fa,n);
    }
}
void create(vector<int> &fa,int n)
{
//cout<<n;
for(int i=2*n-1;i>=n;i--)
    {
    redo(fa,i,0);
    }

}



int main()
{
int n,m;
cin>>n>>m;
vector<int> fa(2*pow(2,n-1),0);
create(fa,pow(2,(n-1)));
//cout<<"a";
for(auto x:fa)
    {
    cout<<x<<endl;
    }

return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/01ms316 KiB
2Wrong answer0/0100ms748 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/31ms316 KiB
8Wrong answer0/31ms364 KiB
9Wrong answer0/31ms316 KiB
10Wrong answer0/31ms316 KiB
11Wrong answer0/2109ms700 KiB
12Wrong answer0/2104ms684 KiB
13Wrong answer0/2104ms680 KiB
14Wrong answer0/2101ms564 KiB
15Wrong answer0/2103ms696 KiB
16Wrong answer0/2103ms564 KiB
17Wrong answer0/2108ms564 KiB
18Wrong answer0/2101ms564 KiB
19Wrong answer0/2104ms564 KiB
20Wrong answer0/3104ms564 KiB
21Wrong answer0/3109ms716 KiB
22Wrong answer0/3101ms564 KiB
23Wrong answer0/397ms564 KiB