#abc347e. E - Set Add Query

E - Set Add Query

Score: 500500 points

问题陈述

存在一个整数序列 A=(A1,A2,,AN)A=(A_1,A_2,\ldots,A_N),长度为 NN,其中所有元素最初都设置为 00。同时,存在一个集合 SS,最初是空的。

按照顺序执行以下 QQ 个查询。在处理所有 QQ 个查询后,找到序列 AA 中每个元素的值。第 ii 个查询的格式如下:

  • 给定一个整数 xix_i。如果整数 xix_i 包含在 SS 中,则从 SS 中移除 xix_i。否则,将 xix_i 插入到 SS 中。然后,对于每个 j=1,2,,Nj=1,2,\ldots,N,如果 jSj\in S,则向 AjA_j 添加 S|S|

这里,S|S| 表示集合 SS 中元素的数量。例如,如果 S={3,4,7}S=\lbrace 3,4,7\rbrace,那么 S=3|S|=3

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

There is an integer sequence A=(A1,A2,,AN)A=(A_1,A_2,\ldots,A_N) of length NN, where all elements are initially set to 00. Also, there is a set SS, which is initially empty.

Perform the following QQ queries in order. Find the value of each element in the sequence AA after processing all QQ queries. The ii-th query is in the following format:

  • An integer xix_i is given. If the integer xix_i is contained in SS, remove xix_i from SS. Otherwise, insert xix_i to SS. Then, for each j=1,2,,Nj=1,2,\ldots,N, add S|S| to AjA_j if jSj\in S.

Here, S|S| denotes the number of elements in the set SS. For example, if S={3,4,7}S=\lbrace 3,4,7\rbrace, then S=3|S|=3.

Constraints

  • 1N,Q2×1051\leq N,Q\leq 2\times10^5
  • 1xiN1\leq x_i\leq N
  • All given numbers are integers.

Input

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

NN QQ

x1x_1 x2x_2 \ldots xQx_Q

Output

Print the sequence AA after processing all queries in the following format:

A1A_1 A2A_2 \ldots ANA_N

Sample Input 1

3 4
1 3 3 2

Sample Output 1

6 2 2

In the first query, 11 is inserted to SS, making S={1}S=\lbrace 1\rbrace. Then, S=1|S|=1 is added to A1A_1. The sequence becomes A=(1,0,0)A=(1,0,0).

In the second query, 33 is inserted to SS, making S={1,3}S=\lbrace 1,3\rbrace. Then, S=2|S|=2 is added to A1A_1 and A3A_3. The sequence becomes A=(3,0,2)A=(3,0,2).

In the third query, 33 is removed from SS, making S={1}S=\lbrace 1\rbrace. Then, S=1|S|=1 is added to A1A_1. The sequence becomes A=(4,0,2)A=(4,0,2).

In the fourth query, 22 is inserted to SS, making S={1,2}S=\lbrace 1,2\rbrace. Then, S=2|S|=2 is added to A1A_1 and A2A_2. The sequence becomes A=(6,2,2)A=(6,2,2).

Eventually, the sequence becomes A=(6,2,2)A=(6,2,2).

Sample Input 2

4 6
1 2 3 2 4 2

Sample Output 2

15 9 12 7