当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5302:Connect the Graph

Special Judge 特殊评判
题目描述
Once there was a special graph. This graph had $n$ vertices and some edges. Each edge was either white or black. There was no edge connecting one vertex and the vertex itself. There was no two edges connecting the same pair of vertices. It is special because the each vertex is connected to at most two black edges and at most two white edges.

One day, the demon broke this graph by copying all the vertices and in one copy of the graph, the demon only keeps all the black edges, and in the other copy of the graph, the demon keeps all the white edges. Now people only knows there are $w_0$ vertices which are connected with no white edges, $w_1$ vertices which are connected with $1$ white edges, $w_2$ vertices which are connected with $2$ white edges, $b_0$ vertices which are connected with no black edges, $b_1$ vertices which are connected with $1$ black edges and $b_2$ vertices which are connected with $2$ black edges.

The precious graph should be fixed to guide people, so some people started to fix it. If multiple initial states satisfy the restriction described above, print any of them.
输入解释
The first line of the input is a single integer $T \ (T \le 700)$, indicating the number of testcases.

Each of the following $T$ lines contains $w_0,w_1,w_2,b_0,b_1,b_2$. It is guaranteed that $1 \le w_0,w_1,w_2,b_0,b_1,b_2 \le 2000$ and $b_0+b_1+b_2=w_0+w_1+w_2$.

It is also guaranteed that the sum of all the numbers in the input file is less than $300000$.
输出解释
For each testcase, if there is no available solution, print $-1$. Otherwise, print $m$ in the first line, indicating the total number of edges. Each of the next $m$ lines contains three integers $x,y,t$, which means there is an edge colored $t$ connecting vertices $x$ and $y$. $t=0$ means this edge white, and $t=1$ means this edge is black. Please be aware that this graph has no self-loop and no multiple edges. Please make sure that $1 \le x, y \le b_0 + b_1 + b_2$.
输入样例
2
1 1 1 1 1 1
1 2 2 1 2 2
输出样例
-1
6
1 5 0
4 5 0
2 4 0
1 4 1
1 3 1
2 3 1
来自杭电HDUOJ的附加信息
Author XJZX
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5302

最后修改于 2020-10-25T23:21:30+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)