https://acs.jxnu.edu.cn/problem/ICPCJX2020E
Color Sequence
1000ms 65536K
描述:
You are given a integer sequence cc of length nn, cici denotes the ithith color in the sequence cc.
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,10,1,0,1 is legal because both color 11 and 00 appear 22 times, and 22 is an even number. And sequence 0,1,00,1,0 is illegal because color 11 only appear 11 time, and 11 is not an even number.
Now, you need to figure out how many consecutive subsequence of cc that is a legal color sequence.
输入:
The first line contains one integer n(1≤n≤106)n(1≤n≤106), the length of the sequence cc.
The second line contains nn integer, the ithith integer denotes the ithith color, ci(0≤ci≤20)ci(0≤ci≤20).
输出:
Print one integer as the answer.
样例输入:
3 1 1 1
样例输出:
2
题目大意:
给定一个长度为nn的整数序列cc,cici表示序列cci中的第一个颜色,我们定义一个颜色序列是合法的,只有当它仅仅包含出现偶数次的颜色时才是合法的。
例如,序列0,1,1,0,10,1 0,1,1,1是合法的,因为颜色11和00都是22倍,而22是偶数,而序列0,1,00,1,0是非法的,因为颜色11出现11次,而11不是偶数。
现在,您需要知道cc的连续子序列有多少个,这是一个合法的颜色序列。
输入:
第一行包含一个整数 n(1≤n≤106)n(1≤n≤106),序列c的长度。
第二行包含nn整数,而ithith整数表示颜色为Ci(0≤cis20)ci(0≤cis20)。
输出:
打印一个整数作为答案。
样例输入:
3 1 1 1
样例输出:
2