D. Array Restoration(树状数组+思维)

这道题目考察的是给定一个经过特定查询操作后的数组,判断是否能通过一系列区间赋值操作恢复到合法状态,并进行恢复。关键在于利用树状数组检查连续段内的值的正确性,以及如何填充0的位置。

Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)

http://codeforces.com/contest/1023/problem/D

D. Array Restoration

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Initially there was an array a

consisting of n integers. Positions in it are numbered from 1 to n

.

Exactly q

queries were performed on the array. During the i-th query some segment (li,ri) (1≤li≤ri≤n) was selected and values of elements on positions from li to ri inclusive got changed to i. The order of the queries couldn't be changed and all q queries were applied. It is also known that every position from 1 to n

got covered by at least one segment.

We could have offered you the problem about checking if some given array (consist

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值