题目:Color Sequence | JXNUOJ
描述:
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.
给你一个整数序列c,长度为n。ci表示在数列c中第i个颜色。
我们定义一个合法的颜色序列,只有当它包括的颜色都只出现偶数次时,才合法。
比如说,序列0,1,0,1就是合法的,因为颜色0和1都出现两次,2又是偶数。序列0,1,0是不合法的,因为颜色1只出现过一次,一又不是偶数。
现在。你需要找出有多少连续的序列c是合法的颜色序列。
输入:
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 ith color, ci(0≤ci≤20).
第一行包括一个整数n(1≤n≤106),序列c的长度。
第二行包括n个正数,第i个整数表示的第i个颜色ci(0≤ci≤20)。
输出:
Print one integer as the answer.
输出一个整数作为答案。
词汇:
even number 偶数 consecutive 连续的