#abc328f. F - Good Set Query
F - Good Set Query
Score : points
问题描述
给定 组整数三元组 $(a_1, b_1, d_1), (a_2, b_2, d_2), \ldots, (a_Q, b_Q, d_Q)$。
集合 的一个子集 被定义为 好集合,如果存在一个长度为 的整数序列 满足以下条件:
对于所有 ,有 。
从空集开始,按顺序对 执行以下操作:
如果 是一个好集合,则用 替换 。
以 升序 打印最终集合 中的所有元素。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given triples of integers $(a_1, b_1, d_1), (a_2, b_2, d_2), \ldots, (a_Q, b_Q, d_Q)$.
A subset of the set is defined to be a good set if there exists an integer sequence of length that satisfies:
for all .
Starting with as an empty set, perform the following operation for in this order:
If is a good set, then replace with .
Print all elements of the final set in ascending order.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the sequence of all elements of the final set in ascending order, separated by spaces, in the following format:
Sample Input 1
3 5
1 2 2
3 2 -3
2 1 -1
3 3 0
1 3 5
Sample Output 1
1 2 4 5
Starting with as an empty set, perform the operation described in the problem statement for in this order, as follows.
- For , the set is a good set, because satisfies the condition in the problem statement, for example, so replace with .
- For , the set is a good set, because satisfies the condition in the problem statement, for example, so replace with .
- For , the set is not a good set.
- For , the set is a good set, because satisfies the condition in the problem statement, for example, so replace with .
- For , the set $S \cup \lbrace i \rbrace = \lbrace 1, 2, 4, 5 \rbrace$ is a good set, because satisfies the condition in the problem statement, for example, so replace with .
Therefore, the final set is .
Sample Input 2
200000 1
1 1 1
Sample Output 2
The final set is empty.
Sample Input 3
5 20
4 2 125421359
2 5 -191096267
3 4 -42422908
3 5 -180492387
3 3 174861038
2 3 -82998451
3 4 -134761089
3 1 -57159320
5 2 191096267
2 4 -120557647
4 2 125421359
2 3 142216401
4 5 -96172984
3 5 -108097816
1 5 -50938496
1 2 140157771
5 4 65674908
4 3 35196193
4 4 0
3 4 188711840
Sample Output 3
1 2 3 6 8 9 11 14 15 16 17 19
update @ 2024/3/10 01:53:16