标签:SFPA th office ai Route bi icpc way roads
Problem Description
Pony is the boss of a courier company. The company needs to deliver packages to n offices numbered from 1 to n. Especially, the s-th office is the transfer station of the courier company. There are x ordinary two-way roads and y one-way roads between these offices. The delivery vans will consume ci power if they pass through the i-th road. In general, the power consumption on one road must be non-negative. However, thanks to the experimental charging rail, the consumption may be negative on some one-way roads. Besides, Pony got the following public information. The relevant department promised that if there is a one-way street from ai to bi, it is impossible to return from bi to ai. To avoid the delivery vans anchoring on the road, Xiaodao wants to find these lowest power consumptions from the transfer station to these offices
Input
The first line contains four integers n (1 ≤ n ≤ 25000); x; y (1 ≤ x; y ≤ 50000), and s (1 ≤ s ≤ n). This is followed by x + y lines, each line of which contains three integer ai; bi (1 ≤ ai; bi ≤ n; ai 6= bi) and ci (−10000 ≤ ci ≤ 10000) describing the roads. The first x given roads are ordinary two-way roads, and the last y given roads are one-way roads.
Output
The output should contain n lines, the i-th line represents the minimum energy consumption from s-th to the i-th office if possible, or output “NO PATH” if it is impossible to reach the i-th office.
Sample Input
6 3 3 4
1 2 5
3 4 5
5 6 10
3 5 -100
4 6 -100
1 3 -10
Sample Output
NO PATH
NO PATH
50
-95
-100
Analysis of ideas
Accepted code
标签:SFPA,th,office,ai,Route,bi,icpc,way,roads 来源: https://www.cnblogs.com/hezongdnf/p/11967069.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。