英文原题:题目来源:Color Sequence | JXNUOJ
Color Sequence
1000ms 65536K
描述:
You are given a integer sequence c of length n, ci denotes the ith color in the sequence c.
We define a color sequence is legal only if it merely contains colors that appear even number of times.
For example, sequence 0,1,0,1 is legal because both color 1 and 0 appear 2 times, and 2 is an even number. And sequence 0,1,0 is illegal because color 1 only appear 1 time, and 1 is not an even number.
Now, you need to figure out how many consecutive subsequence of c that is a legal color sequence.
输入:
The first line contains one integer n(1≤n≤106), the length of the sequence c.
The second line contains n integer, the ith integer denotes the ithith color, ci(0≤ci≤2).
输出:
Print one integer as the answer.
翻译:
颜色序列
描述:
现给一个长度为n的整数序列c,ci表示序列c中的第i种颜色。
我们定义一个颜色序列中包含的所以颜色出现次数皆为偶数次时该序列为合法的序列。
例如,序列0,1,0,10,1,0,1是合法的,因为0和1都出现了2次,而2是一个偶数。与此同时,序列0,1,0是非法的,因为1只出现了1次,而1不是偶数。
现在你需要计算出c序列的子序列里有多少合法的序列。
输入:
第一行输入一个整数n(1≤n≤106)表示序列c的长度。
第二行输入n个整数,第i个整数表示第i个颜色,ci(0≤ci≤2)。
输出:
输出一个整数表示答案。