#P5939. [POI 1998 R3] 折线

[POI 1998 R3] 折线

Problem Description

A 2D Cartesian coordinate system is given.

We require that a polyline can be drawn in one stroke only from left to right, and the angle between each segment of the polyline and the xx-axis is in [45,45][-45^\circ, 45^\circ].

A polyline that satisfies the above requirements is called a straight polyline.

Given nn lattice points on the coordinate plane, what is the minimum number of straight polylines needed to cover all the points?

Input Format

The first line contains a positive integer nn, representing the number of points.

The next nn lines each contain two integers xi,yix_i, y_i, representing the coordinates of the ii-th point.

Output Format

Output a single integer, representing the minimum number of straight polylines required.

5
2 3
3 4
4 5
1 6
12 27
3
6
1 6
10 8
1 5
2 20
4 4
6 2
3

Hint

For 100%100\% of the testdata, 1n300001 \le n \le 30000, 0xi,yi300000 \le x_i, y_i \le 30000.

Translated by ChatGPT 5