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

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

被折叠的 条评论
为什么被折叠?



