Planet Gozz
Planet Gozz calls for aid! They are under attack from the minions of the evil MAX! Gozz has sent out messages to other planets using an FTL email system so all planets receive the message at the same time, but due to some wacky timespace hijinks the receipt time may be years after the send time, or even years before. None of the planets that receive the message have FTL travel, but they do have access to wormholes that allow instantaneous travel through time and space.
A wormhole
Input Specification
The first line contains an integer
Planet Gozz is always at index 0. For any ordered pair of planets
Output Specification
For each test case, output a single line containing the number of planets that can arrive at planet Gozz (index 0) at or before the year the message was sent (year 0) (not including planet Gozz itself).
Bounds
Note this problem includes sub-problems of increasing difficulty worth different numbers of points:
- 30 points:
and - 10 points:
and - 60 points:
and
For all sub-problems:
Sample Input
1
6 1 4
1 0 -2
2 0 -1
3 1 2
1 2 4
3 2 3
2 1 5
Sample Output
2
In the sample test case each planet receives the message in year 1. The shortest path to planet Gozz (planet 0) from planet 1 would take -2 years (1 to 0, arriving in year -1), from planet 2 would take -1 years (2 to 0, arriving in year 0), and from planet 3 would take 0 years (3 to 1 to 0, arriving in year 1). Thus only planets 1 and 2 can arrive by year 0, and the total number is 2. Other paths exist but they would take longer.
Comments