随笔分类 - 图论—最短路
摘要:不知道为什么一个一分的点死活过不去。。。 L3-028 森森旅游 (30 分) 好久没出去旅游啦!森森决定去 Z 省旅游一下。 Z 省有 n 座城市(从 1 到 n 编号)以及 m 条连接两座城市的有向旅行线路(例如自驾、长途汽车、火车、飞机、轮船等),每次经过一条旅行线路时都需要支付该线路的费用(
阅读全文
摘要:It is Zhang3's birthday! Zhang3 has bought a birthday cake and now it's time to take it home. There are n villages, labeled 1,2,…,n. There are m bidir
阅读全文
摘要:Princess CJB has lived almost her entire life in the isolated town of Ertona, where CJB uses her unique ability to recognize where crystals of materia
阅读全文
摘要:You are given an undirected unweighted graph consisting of nn vertices and mm edges (which represents the map of Bertown) and the array of prices pp o
阅读全文
摘要:题目描述 Farmer John 的农场里有很多牧区。有的路径连接一些特定的牧区。一片所有连通的牧区称为一个牧场。但是就目前而言,你能看到至少有两个牧区通过任何路径都不连通。这样,Farmer John 就有多个牧场了。 John 想在牧场里添加恰好一条路径。对这条路径有以下限制: 一个牧场的直径就
阅读全文
摘要:题目背景 “咚咚咚……”“查水表!”原来是查水表来了,现在哪里找这么热心上门的查表员啊!小明感动的热泪盈眶,开起了门…… 题目描述 妈妈下班回家,街坊邻居说小明被一群陌生人强行押上了警车!妈妈丰富的经验告诉她小明被带到了 ttt 区,而自己在 sss 区。 该市有 mmm 条大道连接 nnn 个区,
阅读全文
摘要:题目描述 小A的工作不仅繁琐,更有苛刻的规定,要求小A每天早上在6:00之前到达公司,否则这个月工资清零。可是小A偏偏又有赖床的坏毛病。于是为了保住自己的工资,小A买了一个十分牛B的空间跑路器,每秒钟可以跑2^k千米(k是任意自然数)。当然,这个机器是用longint存的,所以总跑路长度不能超过ma
阅读全文
摘要:题目背景 BBB地区在地震过后,所有村庄都造成了一定的损毁,而这场地震却没对公路造成什么影响。但是在村庄重建好之前,所有与未重建完成的村庄的公路均无法通车。换句话说,只有连接着两个重建完成的村庄的公路才能通车,只能到达重建完成的村庄。 题目描述 给出BBB地区的村庄数NNN,村庄编号从000到N−1
阅读全文
摘要:The map of Bertown can be represented as a set of nn intersections, numbered from 11 to nn and connected by mm one-way roads. It is possible to move a
阅读全文
摘要:题目描述 给出一个NNN个顶点MMM条边的无向无权图,顶点编号为1−N1-N1−N。问从顶点111开始,到其他每个点的最短路有几条。 输入格式 第一行包含222个正整数N,MN,MN,M,为图的顶点数与边数。 接下来MMM行,每行222个正整数x,yx,yx,y,表示有一条顶点xxx连向顶点yyy的
阅读全文
摘要:题目描述 在一个神奇的小镇上有着一个特别的电车网络,它由一些路口和轨道组成,每个路口都连接着若干个轨道,每个轨道都通向一个路口(不排除有的观光轨道转一圈后返回路口的可能)。在每个路口,都有一个开关决定着出去的轨道,每个开关都有一个默认的状态,每辆电车行驶到路口之后,只能从开关所指向的轨道出去,如果电
阅读全文
摘要:题目描述 有一个 nnn 个点 mmm 条边的无向图,请求出从 sss 到 ttt 的最短路长度。 输入格式 第一行四个正整数 n,m,s,tn,m,s,tn,m,s,t。 接下来 mmm 行,每行三个正整数 u,v,wu,v,wu,v,w,表示一条连接 u,vu,vu,v,长为 www 的边。 输
阅读全文
摘要:One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total
阅读全文
摘要:Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whe
阅读全文
摘要:Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but
阅读全文
摘要:An ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to large
阅读全文
摘要:题目描述 CC C国有n n n个大城市和m mm 条道路,每条道路连接这 nnn个城市中的某两个城市。任意两个城市之间最多只有一条道路直接相连。这 mmm 条道路中有一部分为单向通行的道路,一部分为双向通行的道路,双向通行的道路在统计条数时也计为 11 1条。 CC C国幅员辽阔,各地的资源分布情
阅读全文
摘要:Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Be
阅读全文
摘要:Farmer John wants to set up a telephone line at his farm. Unfortunately, the phone company is uncooperative, so he needs to pay for some of the cables
阅读全文