PROGRAMMING:Come Minion!
Welcome treasure hunter! I am the great and powerful interplanetary ninja and you are my
minion. We must hurry to save this planet from the evil, “Dialog Not Found”. We must travel
across the land so that I may prevent “Dialog Not Found” from their evil plans. Also just so you
know, minion, I am unable to triumph over a great many trials. Some of these include being
looked at, handshakes, and even stairs.
The Problem:
Given a map of locations, routes between locations, and the trials which exist along routes, help
the interplanetary ninja reach their target. You must avoid any of the trials that the ninja is
unable to triumph over. Then tell the interplanetary ninja if they are able to reach their target and save the world.
General idea: given some nodes, there is an edge between each two nodes, and there is a special weight "test" on the edge. For example, there is a test "XYZ" between 1 and 2. Then the ninja must be able to withstand this test to pass smoothly. The Ninja knows his own strength, and he knows what tests he can't pass. Now the Ninja starts from node 0, Ask you whether Ninja can reach the last node after a series of tests.
###Input format:
The first input line contains a positive integer, m, indicating the number of maps to check. Each
map will start with an integer on a new line, t (0 ≤ t ≤ 50), that describes the number of trials that
the ninja is unable to accomplish. On the next t lines these trials are listed, one per line. The
following line will contain two integers, n (2 ≤ n ≤ 30) and e (0 ≤ e ≤ 500). n indicates the
number of locations on the map (numbered 0 through n-1) and e indicates the total number of
routes between locations on the map. Assume the ninja’s starting location number is 0 and the
ninja’s target location is n-1.
The following e lines each describe a route between a pair of locations, and the trial on that
route. These lines will consist of two integers La and Lb and a string Q. The ninja can travel
between location La and location Lb, or between Lb and La, as long as he does not have the trial
(Q) on that route. For example, if ninja has the trial “xyz” and the route also has the trial “xyz”,
then ninja cannot travel on that route. Assume that there is at most one route between any two
locations and exactly one trial for a route.
All locations are numbered from 0 to n-1, inclusive. All trials are named using only lowercase
letters, 1 to 20 in length. If a trial is not on the “unable to accomplish” list of ninja, then the
ninja will be able to accomplish it. Successive values on a line are separated by exactly one
space. There are no leading or trailing spaces on any line.
Main idea: first, give the number of data m to be judged, the next line gives the number of tests t that Ninja can't complete, the next line gives the names of tests that Ninja can't complete, then the next line gives N and E, which are node number (from 0 to n-1) and the number of edges, and the next line gives 3 data in each line, which are the two endpoints of the edge and the test on the edge, There is only one and only one test on each side.
###Output format:
For each map, output a line that contains only a 1 if the ninja can reach his target and a 0 if the
ninja is unable to reach his target. Each answer must be on a separate line.
If Ninja can reach the destination (n-1), output 1, otherwise output 0, each output occupies one line.
###Input example:
Here is a set of inputs. For example:
```in
two
three
stairs
talking
staring
4 5
0 3 talking
0 1 abc
0 2 xyz
1 3 stairs
2 3 staring
three
fire
water
people
4 5
0 1 abc
0 2 water
1 2 fire
1 3 xyz
2 3 abc
```
###Output example:
The corresponding output is given here. For example:
```out
0
one
```
answer:If there is no answer, please comment
minion. We must hurry to save this planet from the evil, “Dialog Not Found”. We must travel
across the land so that I may prevent “Dialog Not Found” from their evil plans. Also just so you
know, minion, I am unable to triumph over a great many trials. Some of these include being
looked at, handshakes, and even stairs.
The Problem:
Given a map of locations, routes between locations, and the trials which exist along routes, help
the interplanetary ninja reach their target. You must avoid any of the trials that the ninja is
unable to triumph over. Then tell the interplanetary ninja if they are able to reach their target and save the world.
General idea: given some nodes, there is an edge between each two nodes, and there is a special weight "test" on the edge. For example, there is a test "XYZ" between 1 and 2. Then the ninja must be able to withstand this test to pass smoothly. The Ninja knows his own strength, and he knows what tests he can't pass. Now the Ninja starts from node 0, Ask you whether Ninja can reach the last node after a series of tests.
###Input format:
The first input line contains a positive integer, m, indicating the number of maps to check. Each
map will start with an integer on a new line, t (0 ≤ t ≤ 50), that describes the number of trials that
the ninja is unable to accomplish. On the next t lines these trials are listed, one per line. The
following line will contain two integers, n (2 ≤ n ≤ 30) and e (0 ≤ e ≤ 500). n indicates the
number of locations on the map (numbered 0 through n-1) and e indicates the total number of
routes between locations on the map. Assume the ninja’s starting location number is 0 and the
ninja’s target location is n-1.
The following e lines each describe a route between a pair of locations, and the trial on that
route. These lines will consist of two integers La and Lb and a string Q. The ninja can travel
between location La and location Lb, or between Lb and La, as long as he does not have the trial
(Q) on that route. For example, if ninja has the trial “xyz” and the route also has the trial “xyz”,
then ninja cannot travel on that route. Assume that there is at most one route between any two
locations and exactly one trial for a route.
All locations are numbered from 0 to n-1, inclusive. All trials are named using only lowercase
letters, 1 to 20 in length. If a trial is not on the “unable to accomplish” list of ninja, then the
ninja will be able to accomplish it. Successive values on a line are separated by exactly one
space. There are no leading or trailing spaces on any line.
Main idea: first, give the number of data m to be judged, the next line gives the number of tests t that Ninja can't complete, the next line gives the names of tests that Ninja can't complete, then the next line gives N and E, which are node number (from 0 to n-1) and the number of edges, and the next line gives 3 data in each line, which are the two endpoints of the edge and the test on the edge, There is only one and only one test on each side.
###Output format:
For each map, output a line that contains only a 1 if the ninja can reach his target and a 0 if the
ninja is unable to reach his target. Each answer must be on a separate line.
If Ninja can reach the destination (n-1), output 1, otherwise output 0, each output occupies one line.
###Input example:
Here is a set of inputs. For example:
```in
two
three
stairs
talking
staring
4 5
0 3 talking
0 1 abc
0 2 xyz
1 3 stairs
2 3 staring
three
fire
water
people
4 5
0 1 abc
0 2 water
1 2 fire
1 3 xyz
2 3 abc
```
###Output example:
The corresponding output is given here. For example:
```out
0
one
```
answer:If there is no answer, please comment