-->
当前位置:首页 > 题库

PROGRAMMING:Ad Astra

Luz5年前 (2021-05-10)题库450
In a distant future, new humans may explore the interstellar like this: there are several * * jump points * * distributed in the universe, and human spaceships can jump to other * * jump points * * faster than the speed of light * * at each * * jump point * *. Of course, generally speaking, each jump consumes a certain amount of energy, but because of the influence of unknown matter, some jumps can obtain a certain amount of energy.
Among all the jumping points, the earth, the original home of human beings, is the most special. It is the only jumping point that is "not the destination of any jumping". In other words, it can jump to other points from the earth, but it can't jump to the earth from any other point.
Suppose a spaceship starts an interstellar exploration journey from the earth. Considering the travel cost, the upper limit of energy consumption is set when it reaches the destination. Then there are some jumping points that the spaceship can reach under this energy consumption limit, while some jumping points cannot. Now please program to find all the jump points you can reach.
The following points should be noted:
1. A jump point that can be reached means that when the spacecraft reaches this point, its energy consumption is within the limit; All the points that can be reached refer to the collection of such points, rather than the points that the spacecraft passes through on a single trip. For example, if the spaceship starts from the earth, if the energy limit is only enough to jump to one of the two points of neighboring star or Sirius, it can not reach the two points successively in a single trip, but "all the points that can be reached" includes the two points, that is, from the perspective of jumping ability, the two points are "reachable".
2. Some jumps can increase the energy of the spaceship, and there is the possibility that the spaceship will start from a certain point, jump several times, and return to this point. But the law of energy determines that when we return to this point, the energy of the spacecraft can only be lower than when we started from this point (otherwise, the "perpetual motion machine" will appear).
3. The upper limit of energy consumption refers to the energy consumed when arriving at the destination (a jump point), regardless of the energy state at the midway point. It should be noted that some jumps will increase energy, so this situation is completely possible: when jumping to point a, the energy consumption exceeds the limit, but jumping from point a to point B just increases energy, and when jumping to point B, the total energy consumption does not exceed the limit. At this time, it is considered that point a cannot be reached and point B can be reached.
###Input format:
First, give a positive integer 'n' ('n '< = 2000) in one line, which is the number of jumping points in the universe.
Next, line 'n', line 'I' ('I '='1.. n') describes the information of the jump point numbered I in the following format:
`K '` P1' ` D1 '` P2' ` D2 '... ` PK' ` DK '(space interval)
Where: Integer 'k' is the number of jumping to other points from this jumping point, followed by 'k' for * * non-zero integer * *'pi ''di','pi 'represents the number of jumping to a point, and' Di 'represents the energy change of the spacecraft jumping to' Pi '. If' Di 'is positive, it means that the jumping will increase the energy (increase' Di '), `A negative Di 'indicates that the jump consumes energy (the value consumed is' | di |'). The topic guarantees that the absolute value of the sum of energy consumed (or increased) along the way from the earth to any reachable jumping point does not exceed 10 < sup > 8 < / sup >.
The last line gives a positive integer 'e', which indicates the upper limit of energy consumption set by the spaceship when it departs.
###Output format:
According to the order of the number from small to large, output the number of all jumping points that the spacecraft can reach, and output a number for each line (there is a new line at the end of the line).
Tips:
1. The jumping point of "Earth" is always considered "reachable", and it doesn't need energy to reach this point (because this is the starting point).
1. The number of the earth is not necessarily '1'.
###Input example:
Here is a set of inputs. For example:
```in
six
3 2 -3 4 -5 3 -6
1 6 -6
2 4 -2 5 -2
2 3 -3 6 -3
1 4 4
0
seven
```
###Output example:
The corresponding output is given here. For example:
```out
one
two
three
four
six
```







answer:If there is no answer, please comment