Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

shu problem D

Posted by lin_ at 2006-10-21 13:13:33
Firing range

Time Limit : 2 seconds Memory Limit : 10MB

After reading a novel about the special troops, Tracy dreams of being a special troop too! Now she and her companions were commanded to attack a missile station. But, of course, the enemy arranged army to defend it.

The station's figure is like the picture below:

The station is a circle which is divided into m parts. We call each part a degree. 0 degree is on the top while m-1 degree is the maximal degree. Degrees are numbered clockwise. The red point in the center is the target. Each enemy's firing range covers an arc of the circle. In the picture above, different color stands for different enemy.

Now Tracy wants to know the arcs which are covered by k(k is her lucky number) enemies’ firing range so that they can enter the circle to finish the mission. But she doesn't know how to work on a circle. OK, please help her.

Input:

The input file contains several test cases. For each test case:
the first line contains three numbers n(0<=n<=100000) , m(1<=m<=100000) and k (0<=k<= n),n stand for the number of enemies. Each of the following n lines contains 2 numbers li, ri (-109<=li<ri<=li+m<=109), standing for one firing rangel(in degree).Note li, ri may >=m, (li, ri)<=> (li-m, ri-m), and data like (300, 560) won't appear(because (300,560) = (300,200), li > ri is invalid).

Output:

The first line contains one number p, standing for the number of arcs which weren't covered by fire. The following p lines: each contains 2 numbers li, ri (-109<=li<ri<=109, li<m), separated by one space, standing for a arc. Arcs should be sorted in ascending order by using li as the first keyword, ri as the second keyword.

Sample Input:

4 360 0
50 70
100 170
140 200
270 320

Sample Output:

3
70 100
200 270
320 410


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator