33OJ
登录 注册

D. 区间集合插入询问 / Range Set Insertion Query

    传统题 2000ms 256MiB

区间集合插入询问 / Range Set Insertion Query

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Statement

There are NN sets S1,S2,…,SNS_1,S_2,\ldots,S_N. Initially, S1,S2,…,SNS_1,S_2,\ldots,S_N are all empty sets.

The following operation is performed QQ times on these sets. In the ii-th operation (1≤i≤Q)(1\le i\le Q), a triple of integers (Li,Ri,Xi)(L_i,R_i,X_i) is given, and the operation below is performed.

  • Add XiX_i to SLi,SLi+1,…,SRiS_{L_i},S_{L_i+1},\ldots,S_{R_i}.

For every i=1,2,…,Ni=1,2,\ldots,N, find the number of elements of SiS_i after all operations are finished.

Constraints

  • 1≤N≤2×1051\le N\le2\times10^5
  • 1≤Q≤2×1051\le Q\le2\times10^5
  • 1≤Li≤Ri≤N (1≤i≤Q)1\le L_i\le R_i\le N\ (1\le i\le Q)
  • 1≤Xi≤Q (1≤i≤Q)1\le X_i\le Q\ (1\le i\le Q)
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

  • NN QQ
  • L1L_1 R1R_1 X1X_1
  • L2L_2 R2R_2 X2X_2
  • ⋮\vdots
  • LQL_Q RQR_Q XQX_Q

Output

Output the number of elements of S1S_1, the number of elements of S2,…,S_2,\ldots, the number of elements of SNS_N after all QQ operations are finished, in this order, separated by spaces.

8 5
2 5 1
1 4 2
7 8 1
3 6 3
2 5 2
1 2 3 3 3 1 1 1

After the five operations, the sets are $\lbrace2\rbrace,\lbrace1,2\rbrace,\lbrace1,2,3\rbrace,\lbrace1,2,3\rbrace,\lbrace1,2,3\rbrace,\lbrace3\rbrace,\lbrace1\rbrace,\lbrace1\rbrace$, respectively. Thus, output their numbers of elements, 1,2,3,3,3,1,1,11,2,3,3,3,1,1,1, in this order, separated by spaces.

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
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

ABC478 赛后模拟赛 ✅️

未参加
状态
已结束
规则
IOI
题目
7
开始于
2026-10-10 21:40
结束于
2026-10-24 21:40
持续时间
336 小时
主持人
参赛人数
59