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

33353번 - Good Subsegments 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB83342.857%

문제

You are given an array $a[1..n]$ consisting of $n$ integers from 1ドル$ to $n$. A subsegment $a[\ell..r]$ of the array is its consecutive part from position $\ell$ to position $r,ドル inclusive.

A subsegment $a[\ell..r]$ is $k$-good if the following conditions are satisfied:

  • $r - \ell + 1 \ge 2 \cdot k,ドル so its length is at least 2ドル \cdot k$;
  • $a_{\ell} = a_{\ell + 1} = a_{\ell + 2} = ... = a_{\ell + k - 1},ドル so at least $k$ of its leftmost elements are equal to each other;
  • $a_{r} = a_{r - 1} = a_{r - 2} = ... = a_{r - k + 1},ドル so at least $k$ its rightmost elements are equal to each other;
  • $a_{\ell} = a_r,ドル so its ends are equal.

For each $k$ from 1ドル$ to $\left\lfloor\frac{n}{2}\right\rfloor,ドル find the number of $k$-good subsegments of the given array $a$.

입력

The first line contains an integer $t$ (1ドル \le t \le 5 \cdot 10^5$), the number of test cases. The test cases follow.

The first line of each test case contains an integer $n$ (2ドル \le n \le 5 \cdot 10^5$).

The second line consists of $n$ integers $a_1, a_2, \ldots, a_n$ (1ドル \le a_i \le n$).

The sum of $n$ over all test cases does not exceed 5ドル \cdot 10^5$.

출력

For each test case, print a line with $\left\lfloor\frac{n}{2}\right\rfloor$ integers: the number of $k$-good subsegments for each corresponding $k,ドル starting from 1ドル$.

제한

예제 입력 1

4
10
1 2 2 2 2 2 3 2 2 2
6
1 1 1 2 1 1
9
2 2 1 1 1 2 2 1 1
10
3 2 3 2 4 2 10 10 10 10

예제 출력 1

28 11 3 0 0
10 2 0
16 3 0 0
10 1 0 0 0

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2023 > Day 3: ABalobanov Contest 1 supported by Pinely I번

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

출처

대학교 대회

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

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