#abc359b. B - Couples
B - Couples
Score : points
问题陈述
有 个人排成一行,从左边数第 个人穿着颜色为 的衣服。这里,衣服有 种颜色,从 到 ,每种颜色恰好有两个人穿着。
找出有多少个整数 满足以下条件:
- 在穿着颜色为 的两个人之间恰好有一个人。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
There are people standing in a row, and the person at the -th position from the left is wearing clothes of color . Here, the clothes have colors from to , and exactly two people are wearing clothes of each color.
Find how many of the integers satisfy the following condition:
- There is exactly one person between the two people wearing clothes of color .
Constraints
- Each integer from through appears exactly twice in .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3
1 2 1 3 2 3
Sample Output 1
2
There are two values of that satisfy the condition: and .
In fact, the people wearing clothes of color are at the 1st and 3rd positions from the left, with exactly one person in between.
Sample Input 2
2
1 1 2 2
Sample Output 2
0
There may be no that satisfies the condition.
Sample Input 3
4
4 3 2 3 2 1 4 1
Sample Output 3
3