CF1336B.Xenia and Colorful Gems

普及/提高-

通过率:0%

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 nrn_r red gems, ngn_g green gems and nbn_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 xx , yy and zz , Xenia wants to find the minimum value of (xy)2+(yz)2+(zx)2(x-y)^2+(y-z)^2+(z-x)^2 . As her dear friend, can you help her?

输入格式

The first line contains a single integer tt ( 1t1001\le t \le 100 ) — the number of test cases. Then tt test cases follow.

The first line of each test case contains three integers nr,ng,nbn_r,n_g,n_b ( 1nr,ng,nb1051\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 nrn_r integers r1,r2,,rnrr_1,r_2,\ldots,r_{n_r} ( 1ri1091\le r_i \le 10^9 ) — rir_i is the weight of the ii -th red gem.

The third line of each test case contains ngn_g integers g1,g2,,gngg_1,g_2,\ldots,g_{n_g} ( 1gi1091\le g_i \le 10^9 ) — gig_i is the weight of the ii -th green gem.

The fourth line of each test case contains nbn_b integers b1,b2,,bnbb_1,b_2,\ldots,b_{n_b} ( 1bi1091\le b_i \le 10^9 ) — bib_i is the weight of the ii -th blue gem.

It is guaranteed that nr105\sum n_r \le 10^5 , ng105\sum n_g \le 10^5 , nb105\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

说明/提示

In the first test case, Xenia has the following gems:

If she picks the red gem with weight 77 , the green gem with weight 66 , and the blue gem with weight 44 , she will achieve the most balanced selection with (xy)2+(yz)2+(zx)2=(76)2+(64)2+(47)2=14(x-y)^2+(y-z)^2+(z-x)^2=(7-6)^2+(6-4)^2+(4-7)^2=14 .

首页