[Writeup] 最短的路(2019西湖论剑预选赛)

[复制链接]
查看211 | 回复2 | 2019-6-15 22:34:24 | 显示全部楼层 |阅读模式
本帖最后由 573v3n 于 2019-6-25 09:23 编辑
  1. import queue
  2. connection=[('FloraPrice','E11'),('FloraPrice','E9'),('FloraPrice','75D}'),('NoraFayette','E11'),('NoraFayette','E10'),('NoraFayette','E13'),('NoraFayette','E12'),('NoraFayette','E14'),('NoraFayette','E9'),('NoraFayette','E7'),('NoraFayette','E6'),('E10','SylviaAvondale'),('E10','MyraLiddel'),('E10','HelenLloyd'),('E10','KatherinaRogers'),('VerneSanderson','E7'),('VerneSanderson','E12'),('VerneSanderson','E9'),('VerneSanderson','E8'),('E12','HelenLloyd'),('E12','KatherinaRogers'),('E12','SylviaAvondale'),('E12','MyraLiddel'),('E14','SylviaAvondale'),('E14','75D}'),('E14','KatherinaRogers'),('FrancesAnderson','E5'),('FrancesAnderson','E6'),('FrancesAnderson','E8'),('FrancesAnderson','E3'),('DorothyMurchison','E9'),('DorothyMurchison','E8'),('EvelynJefferson','E9'),('EvelynJefferson','E8'),('EvelynJefferson','E5'),('EvelynJefferson','E4'),('EvelynJefferson','E6'),('EvelynJefferson','E1'),('EvelynJefferson','E3'),('EvelynJefferson','E2'),('RuthDeSand','E5'),('RuthDeSand','E7'),('RuthDeSand','E9'),('RuthDeSand','E8'),('HelenLloyd','E11'),('HelenLloyd','E7'),('HelenLloyd','E8'),('OliviaCarleton','E11'),('OliviaCarleton','E9'),('EleanorNye','E5'),('EleanorNye','E7'),('EleanorNye','E6'),('EleanorNye','E8'),('E9','TheresaAnderson'),('E9','PearlOglethorpe'),('E9','KatherinaRogers'),('E9','SylviaAvondale'),('E9','MyraLiddel'),('E8','TheresaAnderson'),('E8','PearlOglethorpe'),('E8','KatherinaRogers'),('E8','SylviaAvondale'),('E8','BrendaRogers'),('E8','LauraMandeville'),('E8','MyraLiddel'),('E5','TheresaAnderson'),('E5','BrendaRogers'),('E5','LauraMandeville'),('E5','CharlotteMcDowd'),('E4','CharlotteMcDowd'),('E4','TheresaAnderson'),('E4','BrendaRogers'),('E7','TheresaAnderson'),('E7','SylviaAvondale'),('E7','BrendaRogers'),('E7','LauraMandeville'),('E7','CharlotteMcDowd'),('E6','TheresaAnderson'),('E6','PearlOglethorpe'),('E6','BrendaRogers'),('E6','LauraMandeville'),('E1','LauraMandeville'),('E1','BrendaRogers'),('E3','TheresaAnderson'),('E3','BrendaRogers'),('E3','LauraMandeville'),('E3','CharlotteMcDowd'),('E3','flag{'),('E2','LauraMandeville'),('E2','TheresaAnderson'),('KatherinaRogers','E13'),('E13','SylviaAvondale')]
  3. conn={}
  4. for i in connection:

  5.     conn.setdefault(i[0], [])
  6.     conn[i[0]].append(i[1])

  7.     conn.setdefault(i[1], [])
  8.     conn[i[1]].append(i[0])

  9. print(conn)
  10. que=queue.Queue()
  11. que.put(("flag{",[]))
  12. while(not que.empty()):
  13.     person,path=que.get()
  14.     if (person == "75D}"):
  15.         path.append("75D}")
  16.         break
  17.     for i in conn[person]:
  18.         if(not (i in path)):
  19.             tmp=list(path)
  20.             tmp.append(person)
  21.             que.put((i,tmp))
  22. print(path)
  23. print("".join(path))
复制代码

回复

使用道具 举报

Arashialing | 2019-6-16 16:36:01 | 显示全部楼层
记得这题最短路径我们写着脚本有个队员手算出来。。。
回复

使用道具 举报

xiaoguoak | 2019-6-19 08:26:53 | 显示全部楼层
这是个啥
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

7

主题

8

帖子

73

积分

打谱CTF

Rank: 3Rank: 3

积分
73