HBC209482Portal题解

原来我爱你 算法基础篇 39 0
题库丰富多样,涵盖各个领域,全网最全C++题库,让您在练习中不断成长!
. You should complete the missions in the order from 1-st to k-th. Initially you are standing at vectex 1.You have a gun in your hand. When you are at some vertex u, you could shoot the gun at the ground, and then a portal will be built at vertex u. When there are two portals in the factory, assuming they are at u and v, you could transfer between u and v with no cost.You also have a remote controller in your hand. It allows you to close a portal whenever you want and wherever you are. What's more, there could be at most two existing portals. So if you want to create another portal when there exists two, you must use your controller to close one before you create.You need to find the minimum distance you have to walk in order to complete all k missions.

You are now in a big factory. The factory could be recognized as a graph with n vertices and m edges. Every edge has its length. You have k missions to do. The i-th mission is going to vertex a_i a i ​ , picking a block and then sending it to vertex b_i b i ​ . You should complete the missions in the order from 1-st to k-th. Initially you are standing at vectex 1. You have a gun in your hand. When you are at some vertex u, you could shoot the gun at the ground, and then a portal will be built at vertex u. When there are two portals in the factory, assuming they are at u and v, you could transfer between u and v with no cost(just like an edge connecting u and v with length 0). You also have a remote controller in your hand. It allows you to close a portal whenever you want and wherever you are(closing one portal at a time, not all portals at the same time). What's more, there could be at most two existing portals. So if you want to create another portal when there exists two, you must use your controller to close one before you create. You need to find the minimum distance you have to walk in order to complete all k missions.

HBC209482Portal题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
全网最全C++题库,助您挑战自我,突破极限,成为编程领域的佼佼者!

标签: HBC209482Portal题解