CF1764H.Doremy's Paint 2
NOI/NOI+/CTSC
通过率:0%
时间限制:4.00s
内存限制:256MB
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.
Doremy 有 n 桶颜料,用一个长度为 n 的数组 a 表示。其中第 i 桶颜料的颜色为 ai。初始时,ai=i。
Doremy 还有 m 个区间 [li,ri](满足 1≤li≤ri≤n)。每个区间描述一次操作。第 i 次操作的执行方式如下:
- 对每个满足 li<j≤ri 的 j,令 aj:=ali。
此外,Doremy 还选定一个整数 k。她希望对每个从 0 到 m−1 的整数 x,计算在初始数组上依次执行操作 (xmodm)+1, (x+1)modm+1, …, (x+k−1)modm+1 后,数组中不同颜色的种类数。你能帮她算出这些值吗?注意:对每个 x,我们均从初始数组出发,仅按给定顺序执行这 k 次操作。
输入格式
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.
输入的第一行包含三个整数 n、m 和 k(1≤n,m≤2⋅105,1≤k≤m)——分别表示数组 a 的长度、操作总数以及 Doremy 所选择的整数。
接下来的 m 行中,第 i 行包含两个整数 li、ri(1≤li≤ri≤n)——表示第 i 个区间的左右端点。
输出格式
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.
输出 m 个整数。第 (x+1) 个整数应为:从初始数组出发,依次执行操作 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.

在第一个测试用例中,下图分别展示了 x=0,1,2 时所得数组的结果。

输入解题思路,AI测评打分。不知道怎么写?