Codeforces Round #431 (Div. 2) (Codeforces 850C) E. Goodbye Souvenir cdq分治

博客内容介绍了如何使用CDQ分治算法解决一种数据结构问题,该问题涉及到区间查询和单点修改操作。文章通过具体例子说明了如何维护一个数据结构,以支持这些操作,并解释了如何将每个数简化为坐标形式,以及如何在分治过程中使用树状数组进行求解。最后,作者提到在Codeforces Round #431 (Div. 2) (Codeforces 850C) E. Goodbye Souvenir题目中应用此方法并取得了较好的运行时间。
摘要由CSDN通过智能技术生成

E. Goodbye Souvenir
time limit per test
6 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

I won't feel lonely, nor will I be sorrowful... not before everything is buried.

A string of n beads is left as the message of leaving. The beads are numbered from 1 to n from left to right, each having a shape numbered by integers between 1 and n inclusive. Some beads may have the same shapes.

The memory of a shape x in a certain subsegment of beads, is defined to be the difference between the last position and the first position that shape x appears in the segment. The memory of a subsegment is the sum of memories over all shapes that occur in it.

From time to time, shapes of beads change as well as the memories. Sometimes, the past secreted in subsegments are being recalled, and you are to find the memory for each of them.

Input

The first line of input contains two space-s

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值