• 131072K
 

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 NN spots in the jail and MM roads connecting some of the spots. JOJO finds that Pucci knows the route of the former (K-1)(K−1)-th shortest path. If Pucci spots JOJO in one of these K-1K−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 KK-th quickest path to get to the destination. What's more, JOJO only has TT units of time, so she needs to hurry.

JOJO starts from spot SS, and the destination is numbered EE. 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 TT units of time.

Input

There are at most 5050 test cases.

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

The second line contains four numbers S, E, KS,E,K and TT ( 1 \leq S,E \leq N1≤S,E≤N, S \neq ES≠E, 1 \leq K \leq 100001≤K≤10000, 1 \leq T \leq 1000000001≤T≤100000000 ).

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

It is guaranteed that for any two spots there will be only one directed road from spot AA to spot BB (1 \leq A,B \leq N, A \neq B)(1≤A,B≤N,A≠B), but it is possible that both directed road <A,B><A,B> and directed road <B,A><B,A>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).

样例输入复制

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

样例输出复制

yareyaredawa

题目来源

ACM-ICPC 2018 沈阳赛区网络预赛

//图上两点之间的第k最短路径的长度

 #define  P pair<int,int>
#define ph push_back
#define N 1009
#define M 10009
const int inf =0x3f3f3f3f;
int n,m,s,e,k,t;
int dis[N];
vector<P>ve[N],se[N];
void init()
{
for(int i=;i<n;i++) {
ve[i].clear();
se[i].clear();
}
}
struct Node{
int to,w;
bool operator <(const Node&a)const{
return w+dis[to]>a.w+dis[a.to];
}
};
void dijk()
{
priority_queue<P,vector<P>,greater<P> >que;
for(int i=;i<N;i++) dis[i]=inf;
dis[e]=;
que.push({,e});
while(!que.empty()){
P temp=que.top();que.pop();
int v=temp.second;
if(dis[v]<temp.first) continue;
for(int i=;i<se[v].size();i++){//反向边
P p=se[v][i];
int x=p.first,w=p.second;
if(dis[x]>dis[v]+w){
dis[x]=dis[v]+w;
que.push({dis[x],x});
}
}
}
}
int astar()
{
priority_queue<Node>que;
que.push({s,});
k--;
while(!que.empty()){
Node temp=que.top();que.pop();
int v=temp.to;
if(v==e) {
if(k) k--;
else return temp.w;
}
for(int i=;i<ve[v].size();i++){
P p=ve[v][i];
int x=p.first,w=p.second;
que.push({x,w+temp.w});
}
}
return -;
}
int main()
{
while(~scanf("%d%d",&n,&m)){
scanf("%d%d%d%d",&s,&e,&k,&t);
int u,v,w;
for(int i=;i<m;i++)
{
scanf("%d%d%d",&u,&v,&w);
ve[u].ph({v,w});
se[v].ph({u,w});
}
dijk();
if(dis[s]==inf) printf("Whitesnake!\n");
else{
if(s==e) k++;//k+1
int ans=astar();
if(ans<=t&&ans!=-) printf("yareyaredawa\n");
else{
printf("Whitesnake!\n");
}
}
}
return ;
}

图上两点之间的第k最短路径的长度 ACM-ICPC 2018 沈阳赛区网络预赛 D. Made In Heaven的更多相关文章

  1. ACM-ICPC 2018 沈阳赛区网络预赛 D Made In Heaven(第k短路,A*算法)

    https://nanti.jisuanke.com/t/31445 题意 能否在t时间内把第k短路走完. 分析 A*算法板子. #include <iostream> #include ...

  2. ACM-ICPC 2018 沈阳赛区网络预赛 D. Made In Heaven(第k短路模板)

    求第k短路模板 先逆向求每个点到终点的距离,再用dij算法,不会超时(虽然还没搞明白为啥... #include<iostream> #include<cstdio> #inc ...

  3. ACM-ICPC 2018 沈阳赛区网络预赛 D. Made In Heaven(约束第K短路)

    题意:求11到nn的第kk短的路径长度,如果超过TT输出Whitesnake!Whitesnake!,否则输出yareyaredawayareyaredawa. 好无以为 , 这就是一道模板题, 当是 ...

  4. ACM-ICPC 2018 沈阳赛区网络预赛 K Supreme Number(规律)

    https://nanti.jisuanke.com/t/31452 题意 给出一个n (2 ≤ N ≤ 10100 ),找到最接近且小于n的一个数,这个数需要满足每位上的数字构成的集合的每个非空子集 ...

  5. ACM-ICPC 2018 沈阳赛区网络预赛-D:Made In Heaven(K短路+A*模板)

    Made In Heaven One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. ...

  6. ACM-ICPC 2018 沈阳赛区网络预赛 F Fantastic Graph(贪心或有源汇上下界网络流)

    https://nanti.jisuanke.com/t/31447 题意 一个二分图,左边N个点,右边M个点,中间K条边,问你是否可以删掉边使得所有点的度数在[L,R]之间 分析 最大流不太会.. ...

  7. ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph (贪心或有源汇上下界网络流)

    "Oh, There is a bipartite graph.""Make it Fantastic."X wants to check whether a ...

  8. ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph(有源上下界最大流 模板)

    关于有源上下界最大流: https://blog.csdn.net/regina8023/article/details/45815023 #include<cstdio> #includ ...

  9. ACM-ICPC 2018 沈阳赛区网络预赛 Made In Heaven(K短路)题解

    思路:K短路裸题 代码: #include<queue> #include<cstring> #include<set> #include<map> # ...

随机推荐

  1. HDU 1160 FatMouse's Speed LIS DP

    http://acm.hdu.edu.cn/showproblem.php?pid=1160 同样是先按它的体重由小到大排,相同就按speed排就行. 这样做的好处是,能用O(n^2)枚举,因为前面的 ...

  2. Hybrid app(cordova) 环境配置记录

    node版本管理 NVM 安装过程 由于最新版 node 不兼容部分功能,所以需要安装 nvm 切换 node 版本 在 https://github.com/coreybutler/nvm-wind ...

  3. 复习KMP

    KMP刚学的时候,看不懂. 再看,哇!原来是这样! 用的时候,忘了. 为了不再跌倒,我决定,记住吧... 在我看来,KMP一般用于字符串匹配时的防超时优化. 他的精髓就是,利用已经匹配的信息,简化这之 ...

  4. 安装vs2013提示必须安装ie10的解决办法

    虽说应该直接安装ie10,但试了下并不是很顺利,找到如下解决办法,亲测通过. 新建bat文件,内容如下,右键以管理员身份运行,vs即可正常安装. @ECHO OFF :IE10HACK REG ADD ...

  5. i-nex安装教程

    sudo add-apt-repository ppa:i-nex-development-team/stable sudo apt-get updatesudo apt-get i-nex

  6. 造成socket.error: [Errno 99] Cannot assign requested

    socket.error: [Errno 99] Cannot assign requested address 网上你去搜,基本都是说bind的时候,地址已经被用了,都是胡扯.地址被用报的错误应该是 ...

  7. Failed to crunch file

    Failed to crunch file 编译时,出现以上错误,经过多次排除验证,原因尽然是因为路径字符太长了... 编译路径不能超过240个字符

  8. 系统有问题基本出在数据库上,web层无状态

    系统有问题基本出在数据库上,web层无状态.

  9. dstat参数选项

    Usage: dstat [-afv] [options..] [delay [count]]Versatile tool for generating system resource statist ...

  10. javascript 和Jquery 互转

    jQuery对象转成DOM对象: 两种转换方式将一个jQuery对象转换成DOM对象:[index]和.get(index); (1)jQuery对象是一个数据对象,可以通过[index]的方法,来得 ...