P7787 [COCI 2016/2017 #6] Turnir

Description

You are given a sequence of $2^N$ positive integers. In each round, these numbers are compared in the given order: the larger number stays, and the smaller number is eliminated, until only one number remains. Now you are given the initial order of these $2^N$ numbers. Please find, for each number, the maximum round it can survive to.

Input Format

The first line contains an integer $N$. The second line contains $2^N$ integers $A_i$, representing the numbers in the sequence.

Output Format

Output one line with $2^N$ integers, where the $i$-th integer represents the round that the $i$-th number can survive to.

Explanation/Hint

**[Sample Explanation #2]** ![](https://cdn.luogu.com.cn/upload/image_hosting/tricmynf.png) **[Constraints]** For $100\%$ of the testdata, $1\le N\le 20$, $0\le A_i\le 1\times 10^9$. **[Note]** The scoring of this problem follows the original COCI settings, with a full score of $100$. This problem is translated from [COCI2016_2017](https://hsin.hr/coci/archive/2016_2017/) [CONTEST #6](https://hsin.hr/coci/archive/2016_2017/contest6_tasks.pdf) _**T3 TURNIR**_. Translated by ChatGPT 5