计蒜客 ACM-ICPC 2018 沈阳赛区网络预赛 D. Made In Heaven

  • 2018-10-03
  • 15
  • 0

Description:

One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. However, Pucci the father somehow knows it and wants to stop her. There are N spots in the jail and M roads connecting some of the spots. JOJO finds that Pucci knows the route of the former (K-1)-th shortest path. If Pucci spots JOJO in one of these K-1 routes, Pucci will use his stand Whitesnake and put the disk into JOJO’s body, which means JOJO won’t be able to make it to the destination. So, JOJO needs to take the K-th quickest path to get to the destination. What’s more, JOJO only has T units of time, so she needs to hurry.

JOJO starts from spot S, and the destination is numbered E. It is possible that JOJO’s path contains any spot more than one time. Please tell JOJO whether she can make arrive at the destination using no more than T units of time.

Input:

There are at most 50 test cases.

The first line contains two integers N and M (1 \leq N \leq 1000, 0 \leq M \leq 10000). Stations are numbered from 1 to N.

The second line contains four numbers S, E, K and T ( 1 \leq S,E \leq N, S \neq E, 1 \leq K \leq 10000, 1 \leq T \leq 100000000 ).

Then M lines follows, each line containing three numbers U, V and W (1 \leq U,V \leq N, 1 \leq W \leq 1000) . It shows that there is a directed road from U-th spot to V-th spot with time W.

It is guaranteed that for any two spots there will be only one directed road from spot A to spot B (1 \leq A,B \leq N, A \neq B), but it is possible that both directed road and directed road exist.

All the test cases are generated randomly.

Output:

One line containing a sentence. If it is possible for JOJO to arrive at the destination in time, output "yareyaredawa" (without quote), else output "Whitesnake!" (without quote).

Sample Input:

2 2
1 2 2 14
1 2 5
2 1 4

Sample Output:

yareyaredawa

题目链接

判断S到E的第K短路是否小于T,直接套A*算法模板判断第K短路距离。

AC代码:

评论

还没有任何评论,你来说两句吧