Polish version    English version  
  About Olympic -> Problems


 News
 About Olympic
About contest
Problems
I OI 1993/1994
II OI 1994/1995
III OI 1995/1996
IV OI 1996/1997
V OI 1997/1998
VI OI 1998/1999
VII OI 1999/2000
VIII OI 2000/2001
IX OI 2001/2002
X OI 2002/2003
XI OI 2003/2004
XII OI 2004/2005
XIII OI 2005/2006
XIV OI 2006/2007
XV OI 2007/2008
Problems archive
 History of OI
 OI books
 National team
 Olympic camps
 Photo gallery
 Links
 SIO
 MAIN
Niebieskie ksi.eczki
VI Olimpiada Informatyczna 1998/1999

Task: RAK
Author:
Rockets

II stage contest  

There are two separate, n-element sets of points of a two dimensional map: R and W. None triple of points from the set RUW is collinear. Rockets earth-to-earth are located on points from the set R. Enemy objects, which should be destroyed, are located on points from the set W. The rockets may fly only in the straight line and their trajectories cannot intersect. We are about to find for each rocket a target to destroy.

Task

Write a program which:

  • reads from the text file RAK.IN coordinates of the points from the sets R and W,
  • finds the set of n pairwise not-intersecting segments, so that one end of each segment belongs to the set R, while the other belongs to the set W,
  • writes the result into the text file RAK.OUT.

Input

In the first line of the file RAK.IN there is written one integer n, 1<=n<=10000, equal to the number of elements of the sets R and W.

In each of the following 2n lines of the file RAK.IN one pair of integer numbers from the interval [-10000, 10000] is written. Numbers in each pair are separated by a single space. They are coordinates of the point on a map (first coordinate x, then y). The first n lines comprise coordinates of the points from the set R, the last n lines comprise the points from the set W. In the (i+1)-th line there are coordinates of the point ri, in the (i+n+1)-th line there are coordinates of the point wi, 1<= i<= n

Output

The file RAK.OUT should consist of n lines. In the i-th line there should be one integer k(i), such that the segment ri wk(i) belongs to the set of segments which your program found. (This means that the rocket from the point ri destroys an object in the point wk(i)).

Example

For the input file RAK.IN:

4
0 0
1 5
4 2
2 6
1 2
5 4
4 5
3 1
one of the correct answers is the text file RAK.OUT: 
2
1
4
3



Print friendly version