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

27536번 - Stone Arranging 2 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB1861189765.101%

문제

JOI-kun has $N$ go stones. The stones are numbered from 1ドル$ to $N$. The color of each stone is an integer between 1ドル$ and 10ドル^9,ドル inclusive. In the beginning, the color of Stone $i$ (1ドル ≤ i ≤ N$) is $A_i$.

From now, JOI-kun will perform $N$ operations. He will put the stones on the table in a line. The operation $i$ (1ドル ≤ i ≤ N$) will be performed as follows:

  1. JOI-kun will put Stone $i$ on the immediate right of Stone $i - 1$. However, when $i = 1,ドル JOI-kun will put Stone 1ドル$ on the table.
  2. If there is a stone among Stones 1ドル,ドル 2ドル,ドル $\dots,ドル $i - 1$ whose current color is the same as Stone $i,ドル let $j$ be the maximum index of such stones, and JOI-kun will paint all of Stones $j + 1,ドル $j + 2,ドル $\dots,ドル $i - 1$ with the color $A_i$.

In order to confirm whether the operations are correctly performed, JOI-kun wants to know in advance the colors of the stones after all the operations are performed.

Given information of the go stones, write a program which determines the colors of the stones after the N operations are performed.

입력

Read the following data from the standard input.

$N$

$A_1$

$A_2$

$\vdots$

$A_N$

출력

Write $N$ lines to the standard output. The $i$-th line (1ドル ≤ i ≤ N$) should contain the color of Stone $i$ after the $N$ operations are performed.

제한

  • 1ドル ≤ N ≤ 200,000円$.
  • 1ドル ≤ A_i ≤ 10^9$ (1ドル ≤ i ≤ N$).
  • Given values are all integers.

서브태스크

번호배점제한
125

$N ≤ 2,000円$.

235

$A_i ≤ 2$ (1ドル ≤ i ≤ N$).

340

No additional constraints.

예제 입력 1

6
1
2
1
2
3
2

예제 출력 1

1
1
1
2
2
2

The operations are performed as in the following table.

Operation The colors of the stones on the table Explanation
1ドル$ 1ドル$ Stone 1ドル$ is put on the table.
2ドル$ 1,ドル 2$ Stone 2ドル$ is put on the immediate right of Stone 1ドル$.
3ドル$ 1,ドル 2, 1$ Stone 3ドル$ is put on the immediate right of Stone 2ドル$.
1,ドル 1, 1$ Stone 2ドル$ is painted in color 1ドル$.
4ドル$ 1,ドル 1, 1, 2$ Stone 4ドル$ is put on the immediate right of Stone 3ドル$.
5ドル$ 1,ドル 1, 1, 2, 3$ Stone 5ドル$ is put on the immediate right of Stone 4ドル$.
6ドル$ 1,ドル 1, 1, 2, 3, 2$ Stone 6ドル$ is put on the immediate right of Stone 5ドル$.
1,ドル 1, 1, 2, 2, 2$ Stone 5ドル$ is painted in color 2ドル$.

Finally, the colors of Stones 1,ドル 2, 3, 4, 5, 6$ will be 1,ドル 1, 1, 2, 2, 2,ドル respectively.

This sample input satisfies the constraints of Subtasks 1, 3.

예제 입력 2

10
1
1
2
2
1
2
2
1
1
2

예제 출력 2

1
1
1
1
1
1
1
1
1
2

This sample input satisfies the constraints of all the subtasks.

힌트

출처

Olympiad > Japanese Olympiad in Informatics > JOI 2022/2023 1번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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