3394: F.Sorting

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:40 解决:10

题目描述

Bobo has n tuples (a1, b1, c1), (a2, b2, c2), . . . , (an, bn, cn). He would like to find the lexicographically smallest permutation p1, p2, . . . , pn of 1, 2, . . . , n such that for i {2, 3, . . . , n} it holds that

api−1 + bpi−1 / api−1 + bpi−1 + cpi−1   ≤    api + bpi / api + bpi + cpi

输入

The input consists of several test cases and is terminated by end-of-file.

 

The first line of each test case contains an integer n. The i-th of the following n lines contains 3 integers ai, bi and ci.

 

输出

 

For each test case, print n integers p1, p2, . . . , pn seperated by spaces. DO NOT print trailing spaces.

 

Constraint

 

• 1 ≤ n ≤ 103

 

• 1 ≤ ai, bi, ci ≤ 2 × 109

 

• The sum of n does not exceed 104.

 

样例输入 复制

2
1 1 1
1 1 2
2
1 1 2
1 1 1
3
1 3 1
2 2 1
3 1 1

样例输出 复制

2 1
1 2
1 2 3

来源/分类