Game With Triangles
시간 제한2초메모리 제한2048 MB
서로 다른 두 평행선 위의 점들에서 교차하지 않는 삼각형을 최대한 많이 만들고, 정확히 k번의 삼각형 선택으로 얻는 최대 점수를 구합니다.
문제
Even Little John needs money to buy a house. But he recently lost his job; how will he earn money now? Of course, by playing a game that gives him money as a reward! Oh well, maybe not those kinds of games you are thinking about.
There are distinct points on the plane. Initially, your score is . To increase your score, you can perform the following operation:
- Choose three distinct points which are not collinear;
- Increase your score by the area of the triangle formed by these three points;
- Then, erase the three points from the plane.

An instance of the game, where the operation is performed twice.
Let be the maximum number of operations that can be performed. For example, if it is impossible to perform any operation, is . Additionally, define as the maximum possible score achievable by performing the operation exactly times. Here, is defined for all integers such that .
Find the value of , and find the values of for all integers independently.
입력
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains two integers and ().
The second line of each test case contains pairwise distinct integers --- the points on ().
The third line of each test case contains pairwise distinct integers --- the points on ().
It is guaranteed that both the sum of and the sum of over all test cases do not exceed .
출력
For each test case, given that the maximum number of operations is , you must output at most two lines:
- The first line contains the value of ;
- The second line contains integers denoting . You are allowed to omit this line if is .
Note that under the constraints of this problem, it can be shown that all values of are integers no greater than .
힌트
On the first test case, there are points .
It can be shown that you cannot perform two or more operations. The value of is , and you are only asked for the value of .
You can choose , , and as the three vertices of the triangle. After that, your score is increased by the area of the triangle, which is . Then, the three points are erased from the plane. It can be shown that the maximum value of your score after performing one operation is . Therefore, the value of is .
On the fifth test case, there are points.
It can be shown that you cannot perform three or more operations. The value of is , and you are asked for the values and .
To maximize the score with only one operation, you can choose three points , , and . Then, the three points are erased from the plane. It can be shown that the maximum value of your score after performing one operation is . Therefore, the value of is .
To maximize the score with exactly two operations, you can choose the following sequence of operations.
- Choose three points , , and . The three points are erased.
- Choose three points , , and . The three points are erased.
Then, the score after two operations becomes . It can be shown that the maximum value of your score after performing exactly two operations is . Therefore, the value of is .