Stay Hungry,Stay Foolish!

C - Ameba -- ATCODER

C - Ameba

https://atcoder.jp/contests/abc274/tasks/abc274_c

 

题目分析

 

 

 

Code

https://atcoder.jp/contests/abc274/submissions/35890782

int n;
int a;
map<int, int> mplevel;
 
int main()
{
    cin >> n;
 
    mplevel[1] = 0;
    
    for(int i=1; i<=n; i++){
        int child1 = 2*i;
        int child2 = child1 + 1;
        
        cin >> a;
        mplevel[child1] = mplevel[a] + 1;
        mplevel[child2] = mplevel[a] + 1;
    }
 
    int nodenum = 2*n + 1;
    for(int i=1; i<=nodenum; i++){
        cout << mplevel[i] << endl;
    }
 
    return 0;
}
 

 

posted @ 2022-10-24 09:56  lightsong  阅读(39)  评论(0编辑  收藏  举报
Life Is Short, We Need Ship To Travel