307305: CF1336B. Xenia and Colorful Gems
Memory Limit:256 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Xenia and Colorful Gems
题意翻译
给定三个正整数数列 $r,g,b$,长度分别为 $n_r,n_g,n_b$。 您需要在三个数列中各取一个整数 $x,y,z$,使得 $(x-y)^2+(y-z)^2+(z-x)^2$ 最小。 **多组测试数据**,$1 \leq r_i,g_i,b_i \leq 10^9$,$1 \leq n_r,n_g,n_b \leq 10^5$,$1 \leq \sum n_r, \sum n_g,\sum n_b \leq 10^5$。 翻译 by Meatherm题目描述
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. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1336B/f1c62b7a1a43a6f38201f883bcf9e45e175e9eca.png)Recently Xenia has bought $ n_r $ red gems, $ n_g $ green gems and $ n_b $ 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?输入输出格式
输入格式
The first line contains a single integer $ t $ ( $ 1\le t \le 100 $ ) — the number of test cases. Then $ t $ test cases follow. The first line of each test case contains three integers $ n_r,n_g,n_b $ ( $ 1\le n_r,n_g,n_b\le 10^5 $ ) — the number of red gems, green gems and blue gems respectively. The second line of each test case contains $ n_r $ integers $ r_1,r_2,\ldots,r_{n_r} $ ( $ 1\le r_i \le 10^9 $ ) — $ r_i $ is the weight of the $ i $ -th red gem. The third line of each test case contains $ n_g $ integers $ g_1,g_2,\ldots,g_{n_g} $ ( $ 1\le g_i \le 10^9 $ ) — $ g_i $ is the weight of the $ i $ -th green gem. The fourth line of each test case contains $ n_b $ integers $ b_1,b_2,\ldots,b_{n_b} $ ( $ 1\le b_i \le 10^9 $ ) — $ b_i $ is the weight of the $ i $ -th blue gem. It is guaranteed that $ \sum n_r \le 10^5 $ , $ \sum n_g \le 10^5 $ , $ \sum n_b \le 10^5 $ (the sum for all test cases).
输出格式
For each test case, print a line contains one integer — the minimum value which Xenia wants to find.
输入输出样例
输入样例 #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