Gadgets Factory | 프로그래밍의 벗 PivotOJ
PivotOJ

Gadgets Factory

시간 제한: 3000ms메모리 제한: 256MB출처: NEERC Northern Subregional 2010BOJ 3535
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

Mr. Smith is a very rich gadgets fan. As soon as he realized that he cannot buy all the gadgets he wants just because they are not yet produced, he decided to build his own Gadgets Factory.

The Gadgets Factory will be built at a place called ‘Silicon Road”. This road concentrates production of highly technological parts required to produce gadgets. The Silicon Road is straight and the factories are placed very close to it, so the road can be considered as an axis, and factories can be considered as points on it.

There are n parts needed to produce gadgets, and m factories that produce these parts. Mr. Smith wants to minimize the sum of squared distances to the nearest factories that produce each of required parts. Help him to find all the points in which that sum is minimal.

[이미지 1]

입력

The first line of the input file contains integer numbers n and m (1 ≤ n ≤ 10 000; n ≤ m ≤ 100 000).

Next m lines contain pairs of integer numbers xi and pi, xi is the coordinate of i-th factory, and pi is the identifier of the part that it produces (|xi| ≤ 100 000; xi ≤ xi+1; 1 ≤ pi ≤ n).

For each required part there is at least one factory that produces it.

출력

The first line of the output file should contain an integer number k — the number of points where the Gadgets Factory can be built.

Next k lines should contain these points in ascending order. The values should be accurate within an absolute error of 10−6.

예제

예제 1

입력
3 5
-1 3
0 1
2 3
4 2
5 2
출력
1
2.0

예제 2

입력
2 5
1 1
2 2
3 1
4 2
5 1
출력
4
1.5
2.5
3.5
4.5
코드를 제출하려면 로그인하세요.