AT_abc478_d.Range Set Insertion Query

普及-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

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.

有 NN 个集合 S1,S2,…,SNS _ 1,S _ 2,\ldots,S _ N。初始时,S1,S2,…,SNS _ 1,S _ 2,\ldots,S _ N 均为空集。

对这些集合执行 QQ 次如下操作。在第 ii 次操作中(1≤i≤Q1\le i\le Q),给定一个三元组整数 (Li,Ri,Xi)(L _ i,R _ i,X _ i),并执行以下操作:

  • 将 XiX _ i 加入集合 SLi,SLi+1,…,SRiS _ {L _ i},S _ {L _ i+1},\ldots,S _ {R _ i} 中。

对每个 i=1,2,…,Ni=1,2,\ldots,N,求所有操作完成后集合 SiS _ i 的元素个数。

输入格式

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

输入从标准输入中按以下格式给出:

NN QQ
L1L _ 1 R1R _ 1 X1X _ 1
L2L _ 2 R2R _ 2 X2X _ 2
⋮\vdots
LQL _ Q RQR _ Q XQX _ Q

输出格式

Output the number of elements of S1S _ 1,, the number of elements of S2S _ 2,…,,\ldots, the number of elements of SNS _ N after all QQ operations are finished, in this order, separated by spaces.

在所有 QQ 次操作完成后,依次输出集合 S1S _ 1 的元素个数、集合 S2S _ 2 的元素个数、……、集合 SNS _ N 的元素个数,各数之间用空格分隔。

输入输出样例

  • 输入#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}\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.

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.

样例 1 解释:
经过五次操作后,各集合依次为 {2},{1,2},{1,2,3},{1,2,3},{1,2,3},{3},{1},{1}\lbrace2\rbrace,\lbrace1,2\rbrace,\lbrace1,2,3\rbrace,\lbrace1,2,3\rbrace,\lbrace1,2,3\rbrace,\lbrace3\rbrace,\lbrace1\rbrace,\lbrace1\rbrace。因此,按此顺序输出它们的元素个数:1,2,3,3,3,1,1,11,2,3,3,3,1,1,1,各数之间用空格分隔。

约束条件

  • 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)
  • 所有输入值均为整数。

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

首页