eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

The Neighbor

The Neighbor

\includegraphics{https://static.e-olymp.com/content/49/49ded4e9b4e4f9f73497cbcae96d7b9e4ccb5593.jpg} Ivan Ivanovich has been living in sanatorium for one week. He lives in a double room with Petr Petrovich. All was good until once Ivan Ivanovich came to his room and stop near the closed door. “It was Petr Petrovich who took the key!”, Ivan Ivanovich understood (they both share one key of their room). The situation was desperate. Absent-minded Petr Petrovich might forget where he lives and might not return to his room. The only chance is to find Petr Petrovich and to take the key from him. Fortunately, Ivan Ivanovich learned well enough all places, where Petr Petrovich used to be and routes between them. But sight of Ivan Ivanovich was not good and he would see Petr Petrovich only if they were in the same position (in the same place or in the same position of the same route). Ivan Ivanovich has told you all favorite places and routes of Petr Petrovich and maximal speeds of Ivan Ivanovich and Petr Petrovich. Now he asks you if he can catch Petr Petrovich in all cases. For example, Ivan Ivanovich lives on the third floor in point 4. Petr Petrovich might go to the hall of the third floor (point 3), then go down to the hall of the second floor (point 2) and further to the hall of the first floor (point 1). Then Ivan Ivanovich will meet Petr Petrovich for sure moving from point 4 to point 1 via points 3 and 2. The first line of input file contains the quantity of tests K < 25. The next lines contain data of first test, then data of second test and so on. The first line of data for each test contains two integers: the number of points N (point numbers are from 1 to N) and the number of routes M. Further in the next M lines routes data are written: three integers separated by space per line, namely, the start point, the finish point, and the length (in meters) of a route. The length of a route is not less than 1 meter and is not greater than 1000 meters. The routes are bidirectional, so route x→y is equal to route y→x. Routes of the form x→x (loops) are impossible. Also it cannot be two routes x→y and x→y (with the same ends). Routes are not necessarily straight but they cannot intersect except at their end points. You can walk from any point to any another point (maybe via other points). In the last line of each test data there are two integers separated by space: Ivan Ivanovich maximal speed VII and Petr Petrovich maximal speed VPP (in kilometers per hour). It is known that 1<100, 0<1000, 0<15, 0<15. For each test write in separate line “YES” if Ivan Ivanovich is able to meet Petr Petrovich in finite time for sure independently of movement Petr Petrovich. Otherwise output “NO”.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
2
4 3
3 4 10
3 2 4
2 1 4
3 4
3 3
1 2 5
2 3 5
1 3 12
5 5
Вихідні дані #1
YES
NO