RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00300

Obilazak

Unrated 레이팅 미적용
난이도
1s
시간 제한
32MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

\(5^{th}\) round, February \(15^{th}\), 2014

Little Mirko has paid a touristic visit to a village nearby Donji Andrijevci, a town in Slavonia. As it
happens, the arrangement of streets in the village looks awfully familiar to the shape of a perfect binary
tree of the order K. A perfect binary tree of order K consists of \(2^{K}- 1\) nodes arranged in K levels (just
like in the image). Each node contains a building labeled with a house number. Moreover, all buildings
but the ones in the last level have a left and right child (see the image again).

Mirko has visited all the buildings in a village and noted down the exact entrance order. Now he wants
to describe to you how the village looks like, but he can't quite remember. Luckily, he remembers the
way in which he visited the buildings:
1. in the beginning, he was standing in front of the only building in the first level
2. if the building which he is currently standing in front of has a left child which he hasn't visited
yet, he will move in front of the left child
3. if the building doesn't have a left child or he has already visited it, he will enter the current
building and write its house number on his paper
4. if he has already visited the current building and the building has a right child, he will move in
front of the right child
5. if he has visited the current building and its left and right child, he will return to the parent of
the current building

After visiting the villages in the pictures above, the paper would look like this: \(2-1-3\) for the first village
and \(1-6-4-3-5-2-7\) for the second village. Write a programme to help Mirko reconstruct the order of
house numbers on each level.

제약
입력 형식

The first line of input contains the integer K (\(1 \le K \le 10\)), the number of levels of the village Mirko
just visited.
The second line of input contains \(2^{K}\) integers, the sequence of house numbers on Mirko's paper. The
house numbers will be unique and from the interval [1, \(2^{K}\)].
Perfect binary tree of orders 2 and 3
\(5^{th}\) round, February \(15^{th}\), 2014

출력 형식

The output must consist of K lines. The i^{th} line must contain the sequence of house numbers in the i^{th}
level of the village.

예제 1
입력
2
2 1 3
출력
1
2 3
예제 2
입력
3
1 6 4 3 5 2 7
출력
3
6 2
1 4 5 7
설명

Clarification of the first and second example: The examples correspond to the images in the task.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2013/2014 Contest 5

평가 및 의견

Obilazak

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Obilazak

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8