CF1764H.Doremy's Paint 2
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Doremy has n buckets of paint which is represented by an array a of length n . Bucket i contains paint with color ai . Initially, ai=i .
Doremy has m segments [li,ri] ( 1≤li≤ri≤n ). Each segment describes an operation. Operation i is performed as follows:
- For each j such that li<j≤ri , set aj:=ali .
Doremy also selects an integer k . She wants to know for each integer x from 0 to m−1 , the number of distinct colors in the array after performing operations xmodm+1,(x+1)modm+1,…,(x+k−1)modm+1 . Can you help her calculate these values? Note that for each x individually we start from the initial array and perform only the given k operations in the given order.
输入格式
The first line of input contains three integers n , m , and k ( 1≤n,m≤2⋅105 , 1≤k≤m ) — the length of the array a , the total number of operations, and the integer that Doremy selects.
The i -th line of the following m lines contains two integers li , ri ( 1≤li≤ri≤n ) — the bounds of the i -th segment.
输出格式
Output m integers. The (x+1) -th integer should be the number of distinct colors in the array if we start from the initial array and perform operations xmodm+1,(x+1)modm+1,…,(x+k−1)modm+1 .
输入输出样例
输入#1
7 5 5 3 5 2 3 4 6 5 7 1 2
输出#1
3 3 3 3 2
输入#2
10 9 4 1 1 2 3 3 4 7 9 6 8 5 7 2 4 9 10 1 3
输出#2
6 6 7 6 5 5 7 7 7
说明/提示
In the first test case, the picture below shows the resulting array for the values of x=0,1,2 respectively.