CF1336B.Xenia and Colorful Gems
普及+/提高
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.

Recently Xenia has bought nr red gems, ng green gems and nb blue gems. Each of the gems has a weight.
Now, she is going to pick three gems.
Xenia loves colorful things, so she will pick exactly one gem of each color.
Xenia loves balance, so she will try to pick gems with little difference in weight.
Specifically, supposing the weights of the picked gems are x, y and z, Xenia wants to find the minimum value of (x−y)2+(y−z)2+(z−x)2. As her dear friend, can you help her?
Xenia 是一位出身贵族的女孩。由于家庭的刻板与严苛,Xenia 不得不寻找一些方式来自我娱乐。

最近,Xenia 购买了 nr 颗红色宝石、ng 颗绿色宝石和 nb 颗蓝色宝石。每颗宝石都有一个重量。
现在,她将从中挑选三颗宝石。
Xenia 喜爱色彩缤纷的事物,因此她将恰好从每种颜色中各挑选一颗宝石。
Xenia 喜爱平衡,因此她会尽量挑选重量差异较小的宝石。
具体而言,假设所选三颗宝石的重量分别为 x、y 和 z,Xenia 希望最小化 (x−y)2+(y−z)2+(z−x)2 的值。作为她亲爱的朋友,你能帮她实现这一目标吗?
输入格式
The first line contains a single integer t (1≤t≤100) — the number of test cases. Then t test cases follow.
The first line of each test case contains three integers nr,ng,nb (1≤nr,ng,nb≤105) — the number of red gems, green gems and blue gems respectively.
The second line of each test case contains nr integers r1,r2,…,rnr (1≤ri≤109) — ri is the weight of the i-th red gem.
The third line of each test case contains ng integers g1,g2,…,gng (1≤gi≤109) — gi is the weight of the i-th green gem.
The fourth line of each test case contains nb integers b1,b2,…,bnb (1≤bi≤109) — bi is the weight of the i-th blue gem.
It is guaranteed that ∑nr≤105, ∑ng≤105, ∑nb≤105 (the sum for all test cases).
第一行包含一个整数 t(1≤t≤100)—— 表示测试用例的数量。随后是 t 个测试用例。
每个测试用例的第一行包含三个整数 nr,ng,nb(1≤nr,ng,nb≤105)—— 分别表示红色宝石、绿色宝石和蓝色宝石的数量。
每个测试用例的第二行包含 nr 个整数 r1,r2,…,rnr(1≤ri≤109)—— 其中 ri 表示第 i 颗红色宝石的重量。
每个测试用例的第三行包含 ng 个整数 g1,g2,…,gng(1≤gi≤109)—— 其中 gi 表示第 i 颗绿色宝石的重量。
每个测试用例的第四行包含 nb 个整数 b1,b2,…,bnb(1≤bi≤109)—— 其中 bi 表示第 i 颗蓝色宝石的重量。
保证对所有测试用例,有 ∑nr≤105、∑ng≤105、∑nb≤105(即各颜色宝石数量的总和均不超过 105)。
输出格式
For each test case, print a line contains one integer — the minimum value which Xenia wants to find.
对于每个测试用例,输出一行,包含一个整数——Xenia 想要求的最小值。
输入输出样例
输入#1
5 2 2 3 7 8 6 3 3 1 4 1 1 1 1 1 1000000000 2 2 2 1 2 5 4 6 7 2 2 2 1 2 3 4 6 7 3 4 1 3 2 1 7 3 3 4 6
输出#1
14 1999999996000000002 24 24 14
说明/提示
In the first test case, Xenia has the following gems:

If she picks the red gem with weight 7, the green gem with weight 6, and the blue gem with weight 4, she will achieve the most balanced selection with (x−y)2+(y−z)2+(z−x)2=(7−6)2+(6−4)2+(4−7)2=14.
在第一个测试用例中,Xenia 拥有以下宝石:

如果她选择重量为 7 的红色宝石、重量为 6 的绿色宝石以及重量为 4 的蓝色宝石,则可得到最均衡的选择,此时 (x−y)2+(y−z)2+(z−x)2=(7−6)2+(6−4)2+(4−7)2=14。
输入解题思路,AI测评打分。不知道怎么写?