문제
Note: We suggest using a language other than Python to earn full credit on this problem.
Farmer John's () cows are standing in a line, with cow at the front of the line and cow at the back of the line. FJ's cows also come in many different species. He denotes each species with an integer from to . The 'th cow from the front of the line is of species ().
FJ is taking his cows to a checkup at a local bovine hospital. However, the bovine veterinarian is very picky and wants to perform a checkup on the 'th cow in the line, only if it is of species ().
FJ is lazy and does not want to completely reorder his cows. He will perform the following operation exactly once.
Select two integers and such that . Reverse the order of the cows that are between the -th cow and the -th cow in the line, inclusive.
FJ wants to measure how effective this approach is. For each , help FJ find the number of distinct operations () that result in exactly cows being checked. Two operations () and () are different if or .
입력
The first line contains an integer .
The second line contains .
The third line contains .
출력
Output lines with the -th line containing the number of distinct operations () that result in cows being checked.
예제 입력 1
3
1 3 2
3 2 1
예제 출력 1
3
3
0
0
예제 입력 2
3
1 2 3
1 2 3
예제 출력 2
0
3
0
3
예제 입력 3
7
1 3 2 2 1 3 2
3 2 2 1 2 3 1
예제 출력 3
0
6
14
6
2
0
0
0
점수
Inputs 4-6: Inputs 7-13: No additional constraints
코드를 제출하려면 로그인이 필요합니다.
로그인