Universal Cup Judging System

Universal Cup

Time Limit: 2 s Memory Limit: 512 MB Total points: 100
Statistics

你刚买了一盏可以发出任何颜色光的新灯!然而,它的控制方式有点棘手。

我们将颜色表示为三个实数 $(r, g, b)$ 的三元组,每个分量在 $0$ 到 $255$ 之间(包含 $0$ 和 $255$)。灯的控制器有八个按钮,分别对应八种基本颜色:黑色 $(0, 0, 0)$、红色 $(255, 0, 0)$、绿色 $(0, 255, 0)$、蓝色 $(0, 0, 255)$、青色 $(0, 255, 255)$、洋红色 $(255, 0, 255)$、黄色 $(255, 255, 0)$ 和白色 $(255, 255, 255)$。

当你按下颜色为 $c$ 的按钮时,灯的颜色会以每秒 $1$ 个单位距离的速度线性向 $c$ 变化。一旦灯的颜色达到 $c$,它就会停止变化。当然,你也可以在更早的任何时刻停止按下按钮,使灯保持在某个中间状态。不允许同时按下两个或多个按钮。

形式化地,每次按键由一个基本颜色 $(r_c, g_c, b_c)$(其中 $r_c, g_c, b_c$ 均等于 $0$ 或 $255$)和一个非负实数 $d$ 描述。设 $p$ 和 $c = (r_c, g_c, b_c)$ 分别为当前灯的颜色和按钮对应的颜色在三维空间中的点,并设 $\vec{v} = c - p$ 为它们之间的向量。如果 $p = c$,按下此按钮不会产生任何变化。否则,如果你按下该按钮 $d$ 秒,灯的颜色将变为 $p + \frac{\vec{v}}{|\vec{v}|} \cdot \min(d, |\vec{v}|)$。

给定一个目标颜色 $(r, g, b)$,其中 $r, g, b$ 为整数。初始时,灯为黑色。请找到任意一个至多包含 $10$ 次按键的序列,将灯的颜色变为 $(r, g, b)$。保证这样的序列一定存在。

输入格式

每个测试包含多个测试用例。第一行包含测试用例的数量 $t$ ($1 \le t \le 10^4$)。

每个测试用例仅包含一行,包含三个整数 $r, g, b$,表示目标颜色 ($0 \le r, g, b \le 255$)。

输出格式

对于每个测试用例,首先输出一个整数 $m$,表示你序列中的按键次数 ($0 \le m \le 10$)。

然后,按时间顺序输出 $m$ 行,描述序列中的按键。每行必须包含三个整数 $r_c, g_c, b_c$,后跟一个实数 $d$ ($r_c, g_c, b_c \in \{0, 255\}$; $0 \le d \le 10^4$)。

如果你的序列执行后,灯的颜色点与目标点 $(r, g, b)$ 之间的距离不超过 $10^{-6}$,则你的答案被视为正确。

你不需要找到最短序列。如果存在多种解,输出其中任意一个即可。

样例

输入 1

3
105 255 175
174 174 174
0 0 0

输出 1

3
0 255 0 3000.0
0 255 255 119.0
255 255 255 119.0
1
255 255 255 301.376840517
2
255 255 255 50.216
0 0 0 58.0

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.