CF1815F OH NO1 (-2-3-4)
题目描述
给定整数 $n,m$,一个长度为 $n$ 的非负整数序列 $d$,和 $m$ 个三元组 $(a_i,b_i,c_i)$,保证 $a_i
输入格式
第一行输入一个整数 $t(1\leq t\leq10^5)$ 表示数据组数,接下来对于每组数据:
第一行输入两个整数 $n,m(3\leq n,\sum n\leq10^6;1\leq m,\sum m\leq4\times10^5)$。
接下来输入一行 $n$ 个整数表示序列 $d(0\leq d_i\leq10^6)$。
接下来输入 $m$ 行,其中第 $i$ 行输入三个整数 $a_i,b_i,c_i(1\leq a_i
输出格式
对于每组数据:
输出 $m$ 行,其中第 $i$ 行输出三个整数 $x_{ab},x_{bc},x_{ca}(1\leq x_{ab},x_{bc},x_{ca}\leq4)$ 表示对于三元组 $(a_i,b_i,c_i)$ 对应的三条边 $(a_i,b_i),(b_i,c_i),(c_i,a_i)$,你分别选择的 $x$ 的值。
有多组满足要求的操作方案时你可以输出任意一组。
可以证明一定有解。
### 样例解释
对于第一组数据:
- 操作前 $d=[0,0,0,0]$,样例输出给出了如下操作:
- 对于边 $(1,2)$,选择 $x=2$,此后 $d=[2,2,0,0]$。
- 对于边 $(1,3)$,选择 $x=1$,此后 $d=[3,2,1,0]$。
- 对于边 $(2,3)$,选择 $x=3$,此后 $d=[3,5,4,0]$。
- 操作后可以发现 $d$ 中元素互不相等,因此满足题目要求。
对于第二组数据:
- 操作前 $d=[0,0,0,0,0]$。
- 操作后 $d=[12,5,6,7,6]$,可以根据样例输入发现不存在连接节点 $3,5$ 的边,因此满足题目要求。
对于第三组数据:
- 操作前 $d=[3,4,5,6]$。
- 操作后 $d=[19,16,17,20]$,可以发现 $d$ 中元素互不相等,因此满足题目要求。
说明/提示
In the first test case, the initial weights are $ [0,0,0,0] $ . We have added values as follows:
- Added $ 2 $ to vertices $ 1 $ and $ 2 $
- Added $ 1 $ to vertices $ 1 $ and $ 3 $
- Added $ 3 $ to vertices $ 2 $ and $ 3 $
The final weights are $ [3,5,4,0] $ . The output is valid because $ a_1 \neq a_2 $ , $ a_1 \neq a_3 $ , $ a_2 \neq a_3 $ , and that all chosen values are between $ 1 $ and $ 4 $ .
In the second test case, the initial weights are $ [0,0,0,0,0] $ . The weights after the operations are $ [12,5,6,7,6] $ . The output is valid because $ a_1 \neq a_2 $ , $ a_1 \neq a_3 $ , $ a_2 \neq a_3 $ , and that $ a_1 \neq a_4 $ , $ a_1 \neq a_5 $ , $ a_4 \neq a_5 $ , and that all chosen values are between $ 1 $ and $ 4 $ .
In the third test case, the initial weights are $ [3,4,5,6] $ . The weights after the operations are $ [19,16,17,20] $ , so all final weights are distinct, which means no two adjacent vertices have the same weight.