QOJ.ac

QOJ

Time Limit: 0.3 s Memory Limit: 128 MB Total points: 100

#4183. Elaxia 的路线

統計

Time Limit: 1s → 0.3s

最近,Elaxia 和 w** 的关系特别好,他们很想整天在一起,但是大学的学习太紧张了,他们必须合理地安排两个人在一起的时间。Elaxia 和 w** 每天都要奔波于宿舍和实验室之间,他们希望在节约时间的前提下,一起走的时间尽可能的长。 现在已知的是 Elaxia 和 w** 所在的宿舍和实验室的编号以及学校的地图:地图上有 $N$ 个路口,$M$ 条路,经过每条路都需要一定的时间。 具体地说,就是要求无向图中,两对点间最短路的最长公共路径。

输入格式

第一行:两个整数 $N$ 和 $M$(含义如题目描述)。

第二行:四个整数 $x_1$、$y_1$、$x_2$、$y_2$($1 \leq x_1,y_1,x_2,y_2 \leq N$),分别表示 Elaxia 的宿舍和实验室及 w** 的宿舍和实验室的标号(两对点分别 $x_1,y_1$ 和 $x_2,y_2$)。

接下来 $M$ 行:每行三个整数,$u$、$v$、$l$($1 \leq u \leq N$,$1\leq v \leq N$,$1 \leq l \leq 10\,000$),表示 $u$ 和 $v$ 之间有一条路,经过这条路所需要的时间为 $l$。

输出格式

一行,一个整数,表示每天两人在一起的时间(即最长公共路径的长度)。

样例数据

样例输入

9 10
1 6 7 8
1 2 1
2 5 2
2 3 3
3 4 2
3 9 5
4 5 3
4 6 4
4 7 2
5 8 1
7 9 1

样例输出

3

子任务

  • 对于 $30\%$ 的数据,$N \leq 100$;
  • 对于 $60\%$ 的数据,$N \leq 1\,000$;
  • 对于 $100\%$ 的数据,$N \leq 1\,500$,输入数据保证没有重边和自环。
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.