#abc347e. E - Set Add Query
E - Set Add Query
Score: points
问题陈述
存在一个整数序列 ,长度为 ,其中所有元素最初都设置为 。同时,存在一个集合 ,最初是空的。
按照顺序执行以下 个查询。在处理所有 个查询后,找到序列 中每个元素的值。第 个查询的格式如下:
- 给定一个整数 。如果整数 包含在 中,则从 中移除 。否则,将 插入到 中。然后,对于每个 ,如果 ,则向 添加 。
这里, 表示集合 中元素的数量。例如,如果 ,那么 。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
There is an integer sequence of length , where all elements are initially set to . Also, there is a set , which is initially empty.
Perform the following queries in order. Find the value of each element in the sequence after processing all queries. The -th query is in the following format:
- An integer is given. If the integer is contained in , remove from . Otherwise, insert to . Then, for each , add to if .
Here, denotes the number of elements in the set . For example, if , then .
Constraints
- All given numbers are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the sequence after processing all queries in the following format:
Sample Input 1
3 4
1 3 3 2
Sample Output 1
6 2 2
In the first query, is inserted to , making . Then, is added to . The sequence becomes .
In the second query, is inserted to , making . Then, is added to and . The sequence becomes .
In the third query, is removed from , making . Then, is added to . The sequence becomes .
In the fourth query, is inserted to , making . Then, is added to and . The sequence becomes .
Eventually, the sequence becomes .
Sample Input 2
4 6
1 2 3 2 4 2
Sample Output 2
15 9 12 7