HDU - 3499 -(Dijkstra变形+枚举边)
Recently,Shua Shua had a big quarrel with his GF. He is so upset that he decides to take a trip to some other city to avoid meeting her. He will travel only by air and he can go to any city if there exists a flight and it can help him reduce the total cost to the destination. There‘s a problem here: Shua Shua has a special credit card which can reduce half the price of a ticket ( i.e. 100 becomes 50,99 becomes 49. The original and reduced price are both integers. ). But he can only use it once. He has no idea which flight he should choose to use the card to make the total cost least. Can you help him?
InputThere are no more than 10 test cases. Subsequent test cases are separated by a blank line.? 4 4 Harbin Beijing 500 Harbin Shanghai 1000 Beijing Chengdu 600 Shanghai Chengdu 400 Harbin Chengdu 4 0 Harbin Chengdu Sample Output 800 -1 Hint In the first sample,Shua Shua should use the card on the flight from Beijing to Chengdu,making the route Harbin->Beijing->Chengdu have the least total cost 800. In the second sample,there‘s no way for him to get to Chengdu from Harbin,so -1 is needed. 这个题的坑点在于建单向边,然后跑两边Dijkstra相当于处理前缀和后缀 然后枚举边就行了,还有初始化INF要大 可能爆longlong代码: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |