March of the Penguins: Finding Ice Floes for Penguin Gathering, Lecture notes of Dynamics

In this problem, you are given the information about various ice floes in the antarctic region, including their locations, number of penguins present, and the maximum number of times a penguin can jump off each floe before it disappears. Your task is to help the penguins find ice floes where they can all meet without getting wet or damaging the floes. Use the given input to determine the indices of the ice pieces where all penguins can meet.

Typology: Lecture notes

2021/2022

Uploaded on 07/04/2022

Meesx
Meesx 🇳🇱

4.2

(9)

190 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
12125 March of the Penguins
A sample layout of ice floes with 3
penguins on them.
Somewhere near the south pole, a number of penguins are stand-
ing on a number of ice floes. Being social animals, the penguins
would like to get together, all on the same floe. The penguins do
not want to get wet, so they have use their limited jump distance
to get together by jumping from piece to piece. However, tem-
peratures have been high lately, and the floes are showing cracks,
and they get damaged further by the force needed to jump to an-
other floe. Fortunately the penguins are real experts on cracking
ice floes, and know exactly how many times a penguin can jump
off each floe before it disintegrates and disappears. Landing on
an ice floe does not damage it. You have to help the penguins
find all floes where they can meet.
Input
On the first line one positive number: the number of testcases, at
most 100. After that per testcase:
One line with the integer N(1 N100) and a floating-point number D(0 D100000),
denoting the number of ice pieces and the maximum distance a penguin can jump.
Nlines, each line containing xi,yi,niand mi, denoting for each ice piece its Xand Ycoordinate,
the number of penguins on it and the maximum number of times a penguin can jump off this
piece before it disappears (10000 xi, yi10000, 0 ni10, 1 mi200).
Output
Per testcase:
One line containing a space-separated list of 0-based indices of the pieces on which all penguins
can meet. If no such piece exists, output a line with the single number -1’.
Sample Input
2
5 3.5
1 1 1 1
2 3 0 1
3 5 1 1
5 1 1 1
5 4 0 1
3 1.1
-1 0 5 10
0 0 3 9
2 0 1 1
pf2

Partial preview of the text

Download March of the Penguins: Finding Ice Floes for Penguin Gathering and more Lecture notes Dynamics in PDF only on Docsity!

12125 March of the Penguins

A sample layout of ice oes with 3 penguins on them.

Somewhere near the south pole, a number of penguins are stand- ing on a number of ice oes. Being social animals, the penguins would like to get together, all on the same oe. The penguins do not want to get wet, so they have use their limited jump distance to get together by jumping from piece to piece. However, tem- peratures have been high lately, and the oes are showing cracks, and they get damaged further by the force needed to jump to an- other oe. Fortunately the penguins are real experts on cracking ice oes, and know exactly how many times a penguin can jump off each oe before it disintegrates and disappears. Landing on an ice oe does not damage it. You have to help the penguins nd all oes where they can meet.

Input

On the rst line one positive number: the number of testcases, at most 100. After that per testcase:

  • One line with the integer N (1 ≤ N ≤ 100) and a oating-point number D (0 ≤ D ≤ 100000), denoting the number of ice pieces and the maximum distance a penguin can jump.
  • N lines, each line containing xi, yi, ni and mi, denoting for each ice piece its X and Y coordinate, the number of penguins on it and the maximum number of times a penguin can jump off this piece before it disappears (− 10000 ≤ xi, yi ≤ 10000, 0 ≤ ni ≤ 10, 1 ≤ mi ≤ 200).

Output

Per testcase:

  • One line containing a space-separated list of 0-based indices of the pieces on which all penguins can meet. If no such piece exists, output a line with the single number `-1'.

Sample Input

Universidad de Valladolid OJ: 12125 – March of the Penguins 2/

Sample Output