UVa 1193/poj 1328 Radar Installation: greed and interval sourcing

Source: Internet
Author: User
Tags time limit radar

1193-radar Installation

Time limit:3.000 seconds

http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=3634

http://poj.org/problem?id=1328

Assume the coasting is a infinite straight line. Land are in one side of coasting, sea in the other. Each small island are a point locating the sea side. and any radar installation, locating on the coasting, can only cover d distance, so a island in the sea can be C Overed by a RADIUS installation, if the distance between them are at most D .

We use Cartesian coordinate system and defining the coasting is the x -axis. The sea side are above x -axis, and the land side below. Given the position of each island in the sea, and Given the distance of the coverage of the radar installation, your task is to write a program to find the minimal number of radar installations to cover all the islands. Note that the position of a island is represented by its x -y coordinates.

Input

The input consists of several test cases. The ' a ' of each case contains two integers n (1

N

1000) and D , where n is the number of islands in the sea and D are the distance of coverage of T He radar installation. This is followed by n lines each containing two integers representing the coordinate of the position of each Isla nd. Then a blank line follows to separate the cases.

The input is terminated by a line containing pair of zeros.

Output

For each test case output one line consisting of the "test Case number followed" by the minimal number of radar installation S needed. '-1' installation means no solution for this case.

Sample Input

3 2
1 2 to 3 1 2 1 1 2 0 2 0 0


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.