Good Subsegments
시간 제한2초메모리 제한2048 MB
각 k마다 왼쪽 k개와 오른쪽 k개 원소가 각각 같은 값이고 양 끝 값도 같은 부분 구간의 개수를 센다.
문제
You are given an array consisting of integers from to . A subsegment of the array is its consecutive part from position to position , inclusive.
A subsegment is -good if the following conditions are satisfied:
- , so its length is at least ;
- , so at least of its leftmost elements are equal to each other;
- , so at least its rightmost elements are equal to each other;
- , so its ends are equal.
For each from to , find the number of -good subsegments of the given array .
입력
The first line contains an integer (), the number of test cases. The test cases follow.
The first line of each test case contains an integer ().
The second line consists of integers ().
The sum of over all test cases does not exceed .
출력
For each test case, print a line with integers: the number of -good subsegments for each corresponding , starting from .