{"trustable":false,"sections":[{"title":"题目描述","value":{"format":"HTML","content":" \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n \u003cp\u003e有很多魔法城堡,这些城堡通过双向通道连接,走过一条通道需要耗费时间。另外,还存在一些单向的时空黑洞,通过它们可以回到过去。现在有 \u003ci\u003eN\u003c/i\u003e (1 ≤ \u003ci\u003eN\u003c/i\u003e ≤ 500) 个城堡,编号 1,2,3...\u003ci\u003eN\u003c/i\u003e,\u003ci\u003eM\u003c/i\u003e (1 ≤ \u003ci\u003eM\u003c/i\u003e ≤ 2500) 条通道,和 \u003ci\u003eW\u003c/i\u003e (1 ≤ \u003ci\u003eW\u003c/i\u003e ≤ 200) 个黑洞。\u003c/p\u003e\n \u003cp\u003e炸洋芋是一个时间旅行爱好者。他希望从一个城堡出发,经过一些通道和黑洞,回到他出发之前的某个时间。\u003c/p\u003e\n \u003cp\u003e 共有\u003ci\u003eF\u003c/i\u003e (1 ≤ \u003ci\u003eF\u003c/i\u003e ≤ 5) 组数据。对每组数据,判断炸洋芋是否有回到过去的可能性。不存在耗时超过10,000秒的通道,且不存在能带炸洋芋回到10,000秒之前的黑洞。\u003c/p\u003e"}},{"title":"输入格式","value":{"format":"HTML","content":" \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n\u003cp\u003e首先是一个整数F,表示有F个测试样例。\u003cp\u003e\n\u003cp\u003e每个样例第1行:分别是三个空格隔开的整数:N,M和W,表示N个城堡,M条双向通道,W个时空黑洞\u003c/p\u003e\n\u003cp\u003e第2行到M+1行:三个空格分开的整数:U,V和T。描述双向通道:从城堡U到V需要耗费T秒。两个城堡可能由一个以上的通道来连接。\u003c/p\u003e\n\u003cp\u003e第M +2到M+ W+1行:三个空格分开的数字:U,V和T。描述时空黑洞:从城堡U到V可以使时间回溯T秒。\u003c/p\u003e"}},{"title":"输出格式","value":{"format":"HTML","content":" \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\nF行,每行对应一组数据。\n每组数据输出单独的一行,” YES”表示能回到过去,”NO”表示不能回到过去。"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\n\n3 3 1\n1 2 2\n1 3 4\n2 3 1\n3 1 3\n\n3 2 1\n1 2 3\n2 3 4\n3 1 8\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eNO\nYES\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"备注","value":{"format":"HTML","content":"\u003cp\u003e样例2:1-2-3-1回路可满足题意,1-2-3需要时间7秒,3-1时间回溯8秒,总时间-1秒,回到了出发之前。\u003c/p\u003e\n\u003cp\u003e样例输入中的空行是为了观察方便,实际输入中并没有。\u003c/p\u003e"}}]}