QOJ.ac

QOJ

时间限制: 1 s 内存限制: 1024 MB 总分: 100

#5613. 通往储蓄之路

统计

Pat Wholes 负责首都的道路维护工作,而这些道路确实亟需维护。路况极其糟糕,以至于事故几乎每天都在发生,公众对此怨声载道。虽然 Pat 很想铺设城市里的每一条道路,但他同时也想保住自己的工作。铺设所有道路的成本肯定会让市长感到不满,如果 Pat 花费太多,市长肯定会撤换他。因此,现在的决定是:哪些道路需要铺设,哪些不需要?在思考了这个问题以及自己的工作保障后,Pat 想出了一个好主意:既然最终目标是让市长满意,他将只铺设那些位于从市长家到市长办公室的最短路径上的道路。市长上班的路线可能有多条,且长度相等,但这应该仍会留下许多不在任何这些路径上的道路,因此(希望如此)会有许多道路不需要铺设。Pat 来到你位于地下室的隔间,请你计算不需要铺设的道路的总长度。

输入格式

输入的第一行包含四个正整数 $n, m, a, b$ ($n, a, b \le 100, a \neq b$),其中 $n$ 表示城镇中的交叉路口数量(编号为 $1$ 到 $n$),$m$ 表示连接交叉路口的道路数量,$a$ 和 $b$ 分别是市长家和办公室所在的交叉路口编号。接下来的 $m$ 行,每行包含三个数字 $i_1, i_2, \ell$ ($1 \le i_1, i_2 \le n, i_1 \neq i_2, 1 \le \ell \le 100$),表示在交叉路口 $i_1$ 和 $i_2$ 之间存在一条长度为 $\ell$ 的双向道路。任意两个交叉路口之间最多存在一条道路,且 $a$ 和 $b$ 之间至少存在一条路径。

输出格式

输出不需要铺设的所有道路的总长度。

样例

样例输入 1

4 5 1 4
1 2 1
1 3 2
1 4 2
4 2 1
3 4 1

样例输出 1

3

样例输入 2

4 5 1 4
1 2 1
1 3 2
1 4 1
4 2 1
3 4 1

样例输出 2

5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.