CF954D.Fight Against Traffic

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Little town Nsk consists of nn junctions connected by mm 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 ss to work located near junction tt . 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 ss and tt won't decrease.

输入格式

The firt line of the input contains integers nn , mm , ss and tt ( 2<=n<=10002<=n<=1000 , 1<=m<=10001<=m<=1000 , 1<=s,t<=n1<=s,t<=n , sts≠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 ii -th of the following mm lines contains two integers uiu_{i} and viv_{i} ( 1<=ui,vi<=n1<=u_{i},v_{i}<=n , uiviu_{i}≠v_{i} ), meaning that this road connects junctions uiu_{i} and viv_{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 ss and tt .

输入输出样例

  • 输入#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
    
首页