ICPCJX2020E Color Sequence 翻译

描述:

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 ith color, ci(0≤ci≤20).

输出:

Print one integer as the answer.

样例输入:

3
1 1 1

样例输出:

2

原题链接:Color Sequence | JXNUOJ

描述:

给你一个长度为n的整数序列c,ci表示序列c中的第i种颜色。

我们定义一个颜色序列是合法的,只当它只包含了出现了偶数次的颜色。

例如,序列0,1,0,1是合法的,因为颜色1和0都出现了2次,并且2是一个偶数。序列0,1,0是非法的,因为颜色1只出现1次,1不是一个偶数。

现在,你需要计算清楚有多少个c的连续子序列是一个合法的颜色序列。

输入:

第一行包含一个整数n(1≤n≤106),为序列c的长度。

第二行包含n个整数,第i个整数表示第i种颜色, ci(0≤ci≤20)。

输出:

输出一个整数作为答案。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值