QOJ.ac

QOJ

时间限制: 3.0 s 内存限制: 256 MB 总分: 100

#6286. 木棍

统计

Bob 有 12 根长度分别为 $l_1, l_2, \dots, l_{12}$ 的木棍。他想用其中的一些木棍尽可能多地组成三角形。每个三角形由三根不同的木棍 $l_a, l_b, l_c$ 组成,需满足 $l_a + l_b > l_c$,$l_a + l_c > l_b$ 以及 $l_b + l_c > l_a$。如果每根木棍最多只能用于一个三角形,他最多能组成多少个三角形?此外,请给出一种组成这些三角形的方法。

输入格式

输入包含多个测试用例。第一行包含一个整数 $T$,表示测试用例的数量。接下来描述所有测试用例。对于每个测试用例: 唯一的一行包含十二个整数 $l_1, l_2, \dots, l_{12}$。

  • $1 \le T \le 6000$
  • $1 \le l_1, l_2, \dots, l_{12} \le 10^9$

输出格式

对于每个测试用例,首先输出一行 “Case #x: m”,其中 $x$ 是从 1 开始的测试用例编号,$m$ 是可以组成的最大三角形数量。 然后,输出 $m$ 行,每行包含三个整数,表示一个三角形的三条边长。 如果存在多种最优解,请输出其中任意一种。注意,每个测试用例中的每根木棍最多只能使用一次,且输出中每行相邻的两个整数之间应由一个空格分隔。

样例

输入 1

5
1 2 3 1 4 1 5 1 6 1 7
1 2 3 4 5 6 7 8 9 10 11 12
1 2 3 5 8 13 21 34 55 89 144 233
2 3 6 15 27 59 72 83 121 159 201 234
2 2 4 8 16 32 64 128 256 512 1024 1281

输出 1

Case #1: 4
1 1 1
4 3 2
1 1 1
6 7 5
Case #2: 3
6 5 4
10 12 11
9 8 7
Case #3: 0
Case #4: 2
83 121 72
234 159 201
Case #5: 1
1024 1281 512

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.