Logo
(追記) (追記ここまで)

20810번 - Rikka with Employees 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB222100.000%

문제

Recently, Rikka became the boss of a big company. There are $n$ employees in Rikka's company, indexed from 1ドル$ to $n$. Employee 1ドル$ is Rikka herself.

Each employee except Rikka has a direct supervisor. The direct supervisor of the $i$-th employee is the $p_i$-th employee. The supervision relationship constitutes a tree. Employee $u$ is a subordinate of Employee $v$ if and only if $v$ is the direct supervisor or an indirect supervisor of $u$.

To encourage employees, Rikka decides to let each employee experience the feeling of being the boss. To achieve this, Rikka will give some employees a holiday. For an employee, he/she will feel like the boss only when the following three conditions are satisfied:

  • He/she is at work;
  • All his/her subordinates are at work;
  • All employees except he/she and his/her subordinates are on holiday.

Now, Rikka is going to make a plan. In the beginning, all employees are at work. In each day, Rikka can make one of the following actions:

  • Choose an index $i$ and give the $i$-th employee a holiday. This action can be taken only when $i$ is on work;
  • Recall an employee which is on holiday. If there are multiple employees which are on holiday, the employee with the shortest holiday will be back. Since the longer the holiday is, the farther the employee will be from the company, and thus the harder recalling he/she will be. Note that this action can be taken only when there is at least one on-holiday employee;
  • Choose an index $i$ and interview him the feeling of being the boss. This action can be taken only when $i$ is feeling like the boss at this time.

Rikka wants you to make a plan. Since it is expensive to give employees holidays, you are required to make every employee feel like the boss and interview them within 9ドル \times 10^6$ days.

입력

The first line contains a single integer $n\ (1 \leq n \leq 10^5),ドル the number of employees.

The second line contains $n-1$ integers $p_2, \dots, p_n\ (1 \leq p_i < i),ドル representing the direct supervisor of each employee.

출력

Output a single line with a single string. From left to right:

  • Substring "+$x$" represents to give the $x$-th employee a holiday;
  • Substring "$-$" represents to recall an employee;
  • Substring "=$x$" represents to interview the $x$-th employee.

Besides, Substring "!" represents that all actions are finished. Any characters after "!" will be ignored.

Your answer will be regarded as correct if and only if the following three conditions are satisfied:

  • The number of actions is no more than 9ドル \times 10^6$;
  • All actions are valid;
  • For each $x \in [1,n],ドル "=$x$" is invoked exactly once.

제한

예제 입력 1

6
1 1 2 3 3

예제 출력 1

=1+たす1+たす3+たす5+たす6=2+たす2=4-ひく-ひく-ひく-ひく+たす4+たす2=3+たす3+たす6=5-ひく+たす5=6!

힌트

출처

Contest > Open Cup > 2020/2021 Season > Stage 7: Grand Prix of Xiaomi M번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /