当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5636:Shortest Path

题目描述
There is a path graph $G=(V,E)$ with $n$ vertices. Vertices are numbered from $1$ to $n$ and there is an edge with unit length between $i$ and $i + 1$ $(1 \le i < n)$. To make the graph more interesting, someone adds three more edges to the graph. The length of each new edge is $1$.

You are given the graph and several queries about the shortest path between some pairs of vertices.
输入解释
There are multiple test cases. The first line of input contains an integer $T$, indicating the number of test cases. For each test case:

The first line contains two integer $n$ and $m$ $(1 \le n, m \le 10^5)$ -- the number of vertices and the number of queries. The next line contains 6 integers $a_1, b_1, a_2, b_2, a_3, b_3$ $(1 \le a_1,a_2,a_3,b_1,b_2,b_3 \le n)$, separated by a space, denoting the new added three edges are $(a_1,b_1)$, $(a_2,b_2)$, $(a_3,b_3)$.

In the next $m$ lines, each contains two integers $s_i$ and $t_i$ $(1 \le s_i, t_i \le n)$, denoting a query.

The sum of values of $m$ in all test cases doesn't exceed $10^6$.
输出解释
For each test cases, output an integer $S=(\displaystyle\sum_{i=1}^{m} i \cdot z_i) \text{ mod } (10^9 + 7)$, where $z_i$ is the answer for $i$-th query.
输入样例
1
10 2
2 4 5 7 8 10
1 5
3 1
输出样例
7
来自杭电HDUOJ的附加信息
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5636

最后修改于 2020-10-25T23:24:23+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 131072/131072K(Java/Others)