A11766 | Fight Against Traffic
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Little town Nsk consists of $n$ junctions connected by $m$ bidirectional roads. Each road connects two distinct junctions and no two roads connect the same pair of junctions. It is possible to get from any junction to any other junction by these roads. The distance between two junctions is equal to the minimum possible number of roads on a path between them.
In order to improve the transportation system, the city council asks mayor to build one new road. The problem is that the mayor has just bought a wonderful new car and he really enjoys a ride from his home, located near junction $s$ to work located near junction $t$ . Thus, he wants to build a new road in such a way that the distance between these two junctions won't decrease.
You are assigned a task to compute the number of pairs of junctions that are not connected by the road, such that if the new road between these two junctions is built the distance between $s$ and $t$ won't decrease.
In order to improve the transportation system, the city council asks mayor to build one new road. The problem is that the mayor has just bought a wonderful new car and he really enjoys a ride from his home, located near junction $s$ to work located near junction $t$ . Thus, he wants to build a new road in such a way that the distance between these two junctions won't decrease.
You are assigned a task to compute the number of pairs of junctions that are not connected by the road, such that if the new road between these two junctions is built the distance between $s$ and $t$ won't decrease.
输入格式
The firt line of the input contains integers $n$ , $m$ , $s$ and $t$ ( $2<=n<=1000$ , $1<=m<=1000$ , $1<=s,t<=n$ , $s≠t$ ) — the number of junctions and the number of roads in Nsk, as well as the indices of junctions where mayors home and work are located respectively. The $i$ -th of the following $m$ lines contains two integers $u_{i}$ and $v_{i}$ ( $1<=u_{i},v_{i}<=n$ , $u_{i}≠v_{i}$ ), meaning that this road connects junctions $u_{i}$ and $v_{i}$ directly. It is guaranteed that there is a path between any two junctions and no two roads connect the same pair of junctions.
输出格式
Print one integer — the number of pairs of junctions not connected by a direct road, such that building a road between these two junctions won't decrease the distance between junctions $s$ and $t$ .
输入输出样例
输入 #1
5 4 1 5 1 2 2 3 3 4 4 5
输出 #1
0
输入 #2
5 4 3 5 1 2 2 3 3 4 4 5
输出 #2
5
输入 #3
5 6 1 5 1 2 1 3 1 4 4 5 3 5 2 5
输出 #3
3
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted