CF1764H.Doremy's Paint 2

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Doremy has nn buckets of paint which is represented by an array aa of length nn . Bucket ii contains paint with color aia_i . Initially, ai=ia_i=i .

Doremy has mm segments [li,ri][l_i,r_i] ( 1lirin1 \le l_i \le r_i \le n ). Each segment describes an operation. Operation ii is performed as follows:

  • For each jj such that li<jril_i < j \leq r_i , set aj:=alia_j := a_{l_i} .

Doremy also selects an integer kk . She wants to know for each integer xx from 00 to m1m-1 , the number of distinct colors in the array after performing operations xmodm+1,(x+1)modm+1,,(x+k1)modm+1x \bmod m +1, (x+1) \bmod m + 1, \ldots, (x+k-1) \bmod m +1 . Can you help her calculate these values? Note that for each xx individually we start from the initial array and perform only the given kk operations in the given order.

输入格式

The first line of input contains three integers nn , mm , and kk ( 1n,m21051\le n,m\le 2\cdot 10^5 , 1km1 \le k \le m ) — the length of the array aa , the total number of operations, and the integer that Doremy selects.

The ii -th line of the following mm lines contains two integers lil_i , rir_i ( 1lirin1\le l_i\le r_i\le n ) — the bounds of the ii -th segment.

输出格式

Output mm integers. The (x+1)(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+k1)modm+1x \bmod m +1, (x+1) \bmod m + 1, \ldots, (x+k-1) \bmod m +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,2x=0,1,2 respectively.

首页