Polish version    English version  
  About Olympic -> Problems -> V OI 1997/1998


 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
V Olimpiada Informatyczna 1997/1998

Task: LAM
Author: Grzegorz Jakacki, Krzysztof Sobusiak
Flat broken lines

III stage contest  

We have a cartesian coordinate system drawn on a sheet of paper. Let us consider broken lines that can be drawn with a single pencil stroke from the left to the right side of the sheet. We also require that for each segment of the line the angle between the straight line containing this segment and the OX axis belongs to [-45°,45°] range. A broken line fulfilling above conditions is called a flat broken line. Suppose we are given n distinct points with integer coordinates. What is the minimal number of flat broken lines that should be drawn in order to cover all the points (a point is covered by a line if it belongs to this line)?

Example

[example]
For 6 points whose coordinates are (1,6), (10,8), (1,5), (2,20), (4,4), (6,2) the minimal number of flat broken lines covering them is 3.

Task

Write a program that:

  • reads the number of points and their coordinates from the text file LAM.IN;
  • computes the minimal number of flat broken lines that should be drawn to cover all the points;
  • writes the result to the text file LAM.OUT.

Input

In the first line of the input file LAM.IN there is one positive integer n, not greater than 30000, which denotes the number of points. In the following n lines there are coordinates of points. Each line contains two integers x, y separated by a single space, 0 <= x <= 30000, 0 <= y <= 30000. The numbers in the (i+1)-st line, 1 <= i <= n, are the coordinates of the i-th point.

Output

Examples

For the input file LAM.IN:

6
1 6
10 8
1 5
2 20
4 4
6 2
the correct result is the output file LAM.OUT :
3




Print friendly version