logo AlgoBeat OnlineJudge
登录 注册

#213865. [CERC 2021] Airline

内存限制:512 MiB 时间限制:15000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

An airline company offers regular flights involving different airports. Each flight links two airports directly (i.e. without stopping at any other airport) and allows travel in both directions. The flights are arranged such that for any choice of starting airport and destination airport , there exists exactly one sequence of flights between the two airports without visiting any airport more than once. The number of flights in this sequence is called the distance between and .

Were the airline to add another flight, say between airports and , it is possible that for some pairs , another, shorter sequence of flights from to would form. The more pairs affected, the more promising the new connection between and is considered to be. The airline is asking you to help them evaluate several possible additions with respect to this criterion.

输入格式

An airline company offers regular flights involving different airports. Each flight links two airports directly (i.e. without stopping at any other airport) and allows travel in both directions. The flights are arranged such that for any choice of starting airport and destination airport , there exists exactly one sequence of flights between the two airports without visiting any airport more than once. The number of flights in this sequence is called the distance between and .

Were the airline to add another flight, say between airports and , it is possible that for some pairs , another, shorter sequence of flights from to would form. The more pairs affected, the more promising the new connection between and is considered to be. The airline is asking you to help them evaluate several possible additions with respect to this criterion.

输出格式

Output lines; in the -th line, output the number of pairs such that and the distance between airports and would decrease if the original network of flights were supplemented by a direct flight connection between the airports and .

样例

样例输入 1

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

样例输出 1

10
4

数据范围与提示

Input limits

  • , where is the distance between and in the original flight network.