Median on Binary Tree

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Yuuka has a binary tree with vertices which are conveniently labeled with 1,2,,n1, 2, \dots, n. For each i2i \geq 2, there is an edge between vertices ii and i/2\lfloor i / 2 \rfloor. The ii-th vertex has weight w_iw\_i associated with it, and all weights are distinct.

Consider a subtree of the given tree (a subgraph which is itself a tree) which consists of vertices v_1,v_2,,v_kv\_1, v\_2, \dots, v\_k such that w_v_1<w_v_2<<w_v_kw\_{v\_1} < w\_{v\_2} < \dots < w\_{v\_k}. The aa-median of this subtree is then w_v_(ka+1)/2w\_{v\_{\lfloor (k - a + 1) / 2 \rfloor}} for 0a<k0 \leq a < k.

For each a0,1,2,,n1a \in \\{0, 1, 2, \dots, n - 1\\}, find the largest aa-median among all subtrees of the given tree.

입력

The input contains zero or more test cases, and is terminated by end-of-file. For each test case:

The first line contains an integer nn (1n21051 \leq n \leq 2 \cdot 10^5). 

The second line contains nn integers w_1,w_2,,w_nw\_1, w\_2, \dots, w\_n (1w_in1 \leq w\_i \leq n, and the numbers w_1,w_2,,w_nw\_1, w\_2, \dots, w\_n are all distinct). It is guaranteed that the sum of all nn does not exceed 21052 \cdot 10^5.

출력

For each test case, output nn integers M_0,M_1,,M_n1M\_0, M\_1, \dots, M\_{n - 1} where M_aM\_a denotes the largest aa-median.