AT_abc478_d.Range Set Insertion Query
普及-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are N sets S1,S2,…,SN. Initially, S1,S2,…,SN are all empty sets.
The following operation is performed Q times on these sets. In the i-th operation (1≤i≤Q), a triple of integers (Li,Ri,Xi) is given, and the operation below is performed.
- Add Xi to SLi,SLi+1,…,SRi.
For every i=1,2,…,N, find the number of elements of Si after all operations are finished.
有 N 个集合 S1,S2,…,SN。初始时,S1,S2,…,SN 均为空集。
对这些集合执行 Q 次如下操作。在第 i 次操作中(1≤i≤Q),给定一个三元组整数 (Li,Ri,Xi),并执行以下操作:
- 将 Xi 加入集合 SLi,SLi+1,…,SRi 中。
对每个 i=1,2,…,N,求所有操作完成后集合 Si 的元素个数。
输入格式
The input is given from Standard Input in the following format:
N Q
L1 R1 X1
L2 R2 X2
⋮
LQ RQ XQ
输入从标准输入中按以下格式给出:
N Q
L1 R1 X1
L2 R2 X2
⋮
LQ RQ XQ
输出格式
Output the number of elements of S1, the number of elements of S2,…, the number of elements of SN after all Q operations are finished, in this order, separated by spaces.
在所有 Q 次操作完成后,依次输出集合 S1 的元素个数、集合 S2 的元素个数、……、集合 SN 的元素个数,各数之间用空格分隔。
输入输出样例
输入#1
8 5 2 5 1 1 4 2 7 8 1 3 6 3 2 5 2
输出#1
1 2 3 3 3 1 1 1
输入#2
30 20 3 22 11 8 30 10 12 14 7 2 17 4 1 19 12 7 30 15 11 23 2 14 25 17 9 12 7 10 16 7 16 18 19 1 11 14 11 15 4 1 21 6 4 8 10 23 24 11 8 27 10 1 19 12 23 23 16 13 24 12
输出#2
3 4 5 6 6 6 7 7 8 8 9 8 8 9 9 10 9 8 7 7 7 6 7 5 3 2 2 2 2 2
说明/提示
Sample 1 Explanation:
After the five operations, the sets are {2},{1,2},{1,2,3},{1,2,3},{1,2,3},{3},{1},{1}, respectively. Thus, output their numbers of elements, 1,2,3,3,3,1,1,1, in this order, separated by spaces.
Constraints
- 1≤N≤2×105
- 1≤Q≤2×105
- 1≤Li≤Ri≤N (1≤i≤Q)
- 1≤Xi≤Q (1≤i≤Q)
- All input values are integers.
样例 1 解释:
经过五次操作后,各集合依次为 {2},{1,2},{1,2,3},{1,2,3},{1,2,3},{3},{1},{1}。因此,按此顺序输出它们的元素个数:1,2,3,3,3,1,1,1,各数之间用空格分隔。
约束条件
- 1≤N≤2×105
- 1≤Q≤2×105
- 1≤Li≤Ri≤N (1≤i≤Q)
- 1≤Xi≤Q (1≤i≤Q)
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?