CF643G.Choosing Ads
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
One social network developer recently suggested a new algorithm of choosing ads for users.
There are n slots which advertisers can buy. It is possible to buy a segment of consecutive slots at once. The more slots you own, the bigger are the chances your ad will be shown to users.
Every time it is needed to choose ads to show, some segment of slots is picked by a secret algorithm. Then some advertisers are chosen. The only restriction is that it should be guaranteed for advertisers which own at least p% of slots composing this segment that their ad will be shown.
From the other side, users don't like ads. So it was decided to show no more than
ads at once. You are asked to develop a system to sell segments of slots and choose ads in accordance with the rules described above.
某社交网络开发者最近提出了一种为用户选择广告的新算法。
共有 n 个广告位可供广告主购买。广告主可一次性购买一段连续的广告位。拥有的广告位越多,其广告被展示给用户的概率就越大。
每次需要选择待展示的广告时,一个秘密算法会选定某一段广告位区间。随后从中选择若干广告主。唯一约束条件是:对于该区间内所占广告位比例至少为 p% 的广告主,必须保证其广告被展示。
另一方面,用户不喜欢过多广告。因此决定:每次最多仅展示
则广告。你需要设计一套系统,用于出售广告位区间,并依据上述规则选择待展示的广告。
输入格式
The first line of the input contains three integers n, m and p (1 ≤ n, m ≤ 150 000, 20 ≤ p ≤ 100) — the number of slots, the number of queries to your system and threshold for which display of the ad is guaranteed.
Next line contains n integers a__i (1 ≤ a__i ≤ 150 000), where the i-th number means id of advertiser who currently owns the i-th slot.
Next m lines contain queries descriptions. Each description is of one of the following forms:
- 1 l r id (1 ≤ l ≤ r ≤ n, 1 ≤ id ≤ 150 000) — advertiser id bought all slots in a range from l to r inclusive;
- 2 l r (1 ≤ l ≤ r) — you need to choose advertisers for segment [l, r].
输入的第一行包含三个整数 n、m 和 p(1 ≤ n, m ≤ 150000,20 ≤ p ≤ 100)——分别表示广告位数量、对系统的查询次数,以及保证广告展示的阈值。
第二行包含 n 个整数 ai(1 ≤ ai ≤ 150000),其中第 i 个数表示当前拥有第 i 个广告位的广告主编号。
接下来 m 行为查询描述。每条描述属于以下两种形式之一:
1 l r id(1 ≤ l ≤ r ≤ n,1 ≤ id ≤ 150000)——广告主id购买了区间 [l,r] 内的所有广告位;2 l r(1 ≤ l ≤ r ≤ n)——你需要为区间 [l,r] 选择广告主。
输出格式
For each query of the second type answer should be printed in a separate line. First integer of the answer should be the number of advertisements that will be shown
. Next cnt integers should be advertisers' ids.
It is allowed to print one advertiser more than once, but each advertiser that owns at least
slots of the segment from l to r should be in your answer.
对于每个第二类查询,答案应单独成行输出。答案的第一个整数为将要展示的广告数量(即
)。随后的 cnt 个整数为广告主的 ID。
允许在答案中重复输出同一广告主,但凡拥有区间 [l,r] 中至少
个广告位的广告主,其 ID 必须出现在答案中。
输入输出样例
输入#1
5 9 33 1 2 1 3 3 2 1 5 2 1 5 2 1 3 2 3 3 1 2 4 5 2 1 5 2 3 5 1 4 5 1 2 1 5
输出#1
3 1 2 3 2 1 3 2 2 1 3 1 1000 1000 1 5 2 5 3 2 1 5
说明/提示
Samples demonstrate that you actually have quite a lot of freedom in choosing advertisers.
示例表明,您在选择广告主方面实际上拥有相当大的自由度。
输入解题思路,AI测评打分。不知道怎么写?