(xn,yn) on the plane and a non-negative integer boundary k. Each point is a tiny steel ball and k is the draw in force of a ball when it's charged. The draw in power is something very similar for all balls.    In one activity, you can choose a ball I to charge it. When charged, all balls with Manhattan distance all things considered k from ball I move to the situation of ball I. Many balls may have a similar facilitate

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Correct answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science.

You have n particular focuses (x1,y1),… ,(xn,yn) on the plane and a non-negative integer boundary k. Each point is a tiny steel ball and k is the draw in force of a ball when it's charged. The draw in power is something very similar for all balls. 

 

In one activity, you can choose a ball I to charge it. When charged, all balls with Manhattan distance all things considered k from ball I move to the situation of ball I. Many balls may have a similar facilitate after an activity. 

 

All the more officially, for all balls j with the end goal that |xi−xj|+|yi−yj|≤k, we dole out xj:=xi and yj:=yi. 

 

An illustration of an activity. Subsequent to charging the ball in the middle, two different balls move to its position. On the right side, the red dab in the middle is the normal situation of those balls. 

 

Your errand is to observe the base number of activities to move all balls to a similar position, or report that this is outlandish. 

 

Input 

 

The principal line contains a solitary integer t (1≤t≤100) — the number of experiments. 

 

The primary line of each experiment contains two integers n, k (2≤n≤100, 0≤k≤106) — the number of balls and the draw in force, everything being equal, individually. 

 

The accompanying n lines portray the balls' directions. The I-th of these lines contains two integers xi, yi (0≤xi,yi≤105) — the directions of the I-th ball. 

 

It is ensured that all focuses are particular. 

 

Output 

 

For each experiment print a solitary integer — the base number of activities to move all balls to a similar position, or −1 in case it is unthinkable.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education