Monthly Archives: October 2017


Blackgate Penitentiary

Vangelis the Batbear trapped all the members of Joker’s Streetgang in a basement.
Your job as a police officer is to transport all gang members to Blackgate Penitentiary.

To facilitate the transport, you should form a row such that the heights of the gang members are in non-decreasing order. For each gang member you should find the min and the max position where they can be in a valid sorted row and produce a roster with this information.

Input data

Input will start with a line that contains only one integer M, the number of crew members that were arrested. On each of the following M lines there will be a single word N and an integer H separated by a space character, where N is the name and H is the height of the crew member.

Output data

On the output, there will be G lines. Each line will contain in alphabetical order and space separated the names of the crew members that have the same height, followed by the min and the max position where any member of the specific group can be placed.

Limitations and notes

1 ≤ M ≤ 1000
1 ≤ length(N) ≤ 10
120 ≤ H ≤ 250

Names are only composed of characters of the Latin alphabet.


Batman and the Bubbles challenge

Good evening master Wayne.

Joker and his gang attended Black Hat USA 2017 where they learned of a new way on how to damage our city!
Specifically, tomorrow night they will try to damage the water pumps of Gotham using bubbles!
The bubbles cause corrosion to the pumps and in a few hours they will damage them with catastrophic results!
To dash Joker’s plan, besides stopping him, you need to make sure that the city network does not contain loops.
If Joker manages to inject bubbles to the network and they enter a loop, they will still cause damage to that area even though you would have already arrested Joker and his gang.

Given the map of the water distribution system, you need to make sure that the map does not contain loops.

Input data

On the first line there will be an integer T, the number of test cases to follow.
For each test case, there will be 2 input lines:

  1. On the first line of the test case, there will be 2 integers V and E, where V is the number of vertices and E is the number of edges.
  2. On the second line, there will be E pairs of integers separated by a space character. Each pair shows a two way connection between vector A with vector B.

Output data

For each test case you will have to write one line that contains an integer, in the case where there is a loop you will write the number 1 or else you will write the number 0.

Limitations and notes

1 ≤ T ≤ 1000
1 ≤ V ≤ 1000
1 ≤ E ≤ 10000
0 ≤ A,B ≤ V-1

Vangelis the bear is Batman! (or Batbear to be more precise).

Vangelis the bear is Batman! (or Batbear to be more precise).

Reading material

Supplementary material

  • Random test case generator – [download id=”3801″]