【BFS】营救天使

Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison. 

Angel’s friends want to save Angel. Their task is: approach Angel. We assume that “approach Angel” is to get to the position where Angel stays. When there’s a guard in the grid, we must kill him (or her?) to move into the grid. We assume that we moving up, down, right, left takes us 1 unit time, and killing a guard takes 1 unit time, too. And we are strong enough to kill all the guards. 

You have to calculate the minimal time to approach Angel. (We can move only UP, DOWN, LEFT and RIGHT, to the neighbor grid within bound, of course.) 

继续阅读【BFS】营救天使

SDAU训练日志第48篇(2018年11月25日)

轮到我们17级给萌新们讲算法了,没想到第一个上场的就是我,有些小紧张,嘻嘻嘻。

昨晚照着原来书上的课件弄今天讲课的课件(原来的课件是真的丑ORZ),折腾到一点半,终于也没白费功夫,今天的讲课过程十分的顺利,讲到最后出了几道变形题他们也能正确的分析出来思路,感觉他们比大一时候的我厉害多了呀,哈哈哈。

第14周有四场考试,JAVA,通信,毛泽东,电子。。。令人头秃。还有四级压着,考试月的到来真的压力大啊。

未来几天重点做算法题和复习英语吧,只看知识点也没啥目的性,试试以战养战。

POJ1258【MST】Agri-Net

Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 29613 Accepted: 11750

Description

Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course. 
Farmer John ordered a high speed connection for his farm and is going to share his connectivity with the other farmers. To minimize cost, he wants to lay the minimum amount of optical fiber to connect his farm to all the other farms. 
Given a list of how much fiber it takes to connect each pair of farms, you must find the minimum amount of fiber needed to connect them all together. Each farm must connect to some other farm such that a packet can flow from any one farm to any other farm. 
The distance between any two farms will not exceed 100,000.