#K74752. Issue Reporting Propagation

    ID: 34267 Type: Default 1000ms 256MiB

Issue Reporting Propagation

Issue Reporting Propagation

You are given a network of n nodes, each identified by its 2D coordinates. An issue reported at node 0 propagates to any other node within a radius r in one unit of time. The propagation is transitive, i.e. if node A can affect node B, and node B can affect node C, then node A will eventually affect node C.

The Euclidean distance between two nodes with coordinates \( (x_1, y_1) \) and \( (x_2, y_2) \) is given by:

\( d = \sqrt{(x_1-x_2)^2 + (y_1-y_2)^2} \)

Your task is to determine the maximum time required for the issue to propagate to all nodes, starting from node 0, if it is possible within a given time limit t. If the propagation cannot reach all nodes within time t, output -1.

inputFormat

The input is read from standard input in the following format:

n r t
x0 y0
x1 y1
... 
xn-1 yn-1

Where:

  • n is the number of nodes.
  • r is the propagation radius.
  • t is the time limit.
  • Each of the next n lines contains two integers representing the coordinates of a node.

outputFormat

Print a single integer to standard output: the maximum propagation time required for the issue to reach all nodes if it is within the time limit t, otherwise print -1.

## sample
4 5 10
0 0
3 4
-3 -4
6 8
2