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

Birokracija

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

의견: 0

설명

1 \(s / 64\) \(MB / 100\) points

Mirko has become CEO of a huge corporation. This corporation consists of \(N\) people,

labeled from 1 to \(N\) , and Mirko is labeled 1. The corporation is structured so that each

employee (except Mirko) has a boss, and we say that employee is an assistant to that boss.

Each boss can have multiple assistants, but still reports to their boss. This holds for

everyone except Mirko, who is at the top of the pyramid and doesn’t have a boss, but has his

assistants.

When Mirko gets a task from the investors, he then delegates that task to his assistant with

the minimal number. This assistant then delegates the task to their assistant with the

minimal number, and this process repeats until the task is given to an unlucky person

without an assistant, who then must do the task.

This is when the real problems begin. The person that did the task gets paid 1 coin, the boss

of that person gets 2 coins, the boss of that person gets 3 coins, and so on, all the way to

Mirko, who gets as many coins as there are people in this sequence. After that, the

employee that really did the job realizes how unfair the system is and quits their job out of

principle.

When it comes to doing the next task in the corporation, there is a person less, so maybe the

paychecks are less, but the work must continue. Tasks are piling up, so the whole procedure

(assigning a new task, doing it, dividing paychecks and the person doing the task quitting)

repeats until Mirko is left alone in the corporation and does his first (also his last) task.

Of course, Mirko will have amassed quite a fortune until then, but he also wants to know how

much money each of the employees earned.

제약

In test cases worth 50% of total points, it will hold 2 ≤ \(N\) ≤ 5000.

1 \(s / 64\) \(MB / 100\) points

입력 형식

The first line of input contains the positive integer \(N\) (2 ≤ \(N \le 2 \cdot 10\) {5}{ }), the number of

employees (including Mirko).
The following line contains \(N\) - 1 positive integers \(a\) {2}{ }, \(a\) {3}{ }, \(a\) {4}{ }, ..., \(a\) {n} (1 ≤ \(a\) } < \(i\) ), where \(a\) _{i

denotes the boss of employee \(i\) .

출력 형식

You must output a single line consisting of \(N\) numbers, the \(i\) ^{th} number corresponding to the

amount of money earned by the \(i\) {th}{ } employee.

예제 1
입력
3
1 1
출력
5 1 1
예제 2
입력
5
1 2 2 4
출력
13 8 1 3 1
문제 정보

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

출처 COCI 2017/2018 Contest 5

평가 및 의견

Birokracija

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

Log in to rate problems.

개별 의견

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

풀이 제출

Birokracija

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