Lots of Circles

2.4

5 votes
Mathematics, Medium, Approved
Problem

This is an approximation problem

Cat Noku arranging n circles for a party.

The i-th circle has radius ri and weight wi.

Cat Noku must arrange the circles in the plane such that no two overlap.

Let (xi,yi) be the final position of the center of the i-th circle in the arrangement. The coordinates must be at integer positions.

Then, his score will equal ni=1wini=1wix2i+y2i109. His score will be zero if any two circles are overlapping. It is ok for two circles to touch.

Find any such arrangement that maximizes the score. Note, this is an approximation problem, so you do not need to find an optimal answer.

Input Format

The first line of input will contain a single integer n. The next n lines of input will each contain two integers ri,wi.

Output Format

Print n lines with two integers each. The i-th line denotes the center of the i-th circle in the arrangement.

The absolute values of the output coordinates must be at most 10^9.

Test case generation

n will be chosen uniformly at random between 3 and 1,000.

ri,wi will be chosen uniformly at random between 1 and 1,000.

During the contest, 100 tests will be provided. After the contest ends, 100 additional cases will be generated, and the combined results will be used to determine your final score.

Sample Input
3
3 5
2 3
1 4
Sample Output
2 3
-2 0
1 -1
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

enter image description here

Editor Image

?