Connecting segments
题号:NC16845
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Niuniu has N directed segments. Each segment has one color. He wants to make a powerful sword by connecting the segments. He can choose at most K segments. He isn’t allowed to choose more than one segment from each color, or rotate segments. The powerfulness of the sword is calculated by the square of the distance between the beginning of the first segment and the end of the last segment. Niuniu wants to know the largest powerfulness when K = 1,…, N.

输入描述:

The input has the format as described below.

N
x1 y1 c1
x2 y2 c2
...
xn yn cn

N is the number of segments. (1 ≤ N ≤ 1000)  The ith segment starts at (0,0), ends at(xi,yi), with color ci. (-1000000 ≤ xi,yi ≤ 1000000,   xi2+yi2>0,   1 ≤ ci ≤ n)

输出描述:

You should output the answers in one line, separated by a space.
示例1

输入

复制
4
1 2 1
2 1 1
2 3 2
3 1 2

输出

复制
13 34 34 34
示例2

输入

复制
2
1 1 1
-1 -1 2

输出

复制
2 2
示例3

输入

复制
10
1 4 1
-2 3 2
3 2 1
2 5 3
-4 2 3
-3 3 1
3 1 2
-10 -10 4
7 7 4
7 7 5

输出

复制
200 392 617 818 976 976 976 976 976 976

备注:

You can consider the segment in this problem as 2D vector.