#547
Unrated
HILO
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Bessie knows a number x+0.5x+0.5 where xx is some integer between 00 to N,N, inclusive (1N21051\le N\le 2 \cdot 10^5).

Elsie is trying to guess this number. She can ask questions of the form "is ii high or low?" for some integer ii between 11 and N,N, inclusive. Bessie responds by saying "HI" if ii is greater than x+0.5x+0.5, or "LO" if ii is less than x+0.5x+0.5.

Elsie comes up with the following strategy for guessing Bessie's number. Before making any guesses, she creates a list of NN numbers, where every number from 11 to NN occurs exactly once (in other words, the list is a permutation of size NN). Then she goes through the list, guessing numbers that appear in the list in order.

However, Elsie skips any unnecessary guesses. That is, if Elsie is about to guess some number ii and Elsie previously guessed some j<ij < i and Bessie responded with "HI", Elsie will not guess ii and will move on to the next number in the list. Similarly, if she is about to guess some number ii and she previously guessed some j>ij > i and Bessie responded with "LO", Elsie will not guess ii and will move on to the next number in the list. It can be proven that using this strategy, Elsie always uniquely determines xx regardless of the permutation she creates.

If we concatenate all of Bessie's responses of either "HI" or "LO" into a single string SS, then the number of times Bessie says "HILO" is the number of length 44 substrings of SS that are equal to "HILO."

Bessie knows that Elsie will use this strategy; furthermore, she also knows the exact permutation that Elsie will use. However, Bessie has not decided on what value of xx to choose.

Help Bessie determine how many times she will say "HILO" for each value of xx.

입력

The first line contains N.N.

The second line contains Elsie's permutation of size N.N.

출력

For each xx from 00 to NN, inclusive, output the number of times Bessie will say HILO on a new line.

예제 입력 1

5
5 1 2 4 3

예제 출력 1

0
1
1
2
1
0

점수

Tests 1 to 4 satisfy N5000N \leq 5000.Tests 5 to 8 have a uniformly random permutation.Tests 9 to 20 satisfy no further constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.