21676_Trave

2022-5-16 18:20| 发布者: Hocassian| 查看: 24| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505750385600-Problem List-采集的数据-后羿采集器.html

Pro.ID

21676

Title

Travel

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21676

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    One day, Tom traveled to a country named BGM. BGM is a small country, but there are N ( N ≤ 100 ) towns in it. Each town products one kind of food, the food will be transported to all the towns. In addition, the trucks will always take the shortest way. There are M ( M ≤ 3000 ) two-way roads connecting the towns, and the length of the road is 1.

    Let SUM be the total distance of the shortest paths between all pairs of the towns. Please write a program to calculate the new SUM after one of the M roads is destroyed.

    输入

    The input contains several test cases.

    The first line contains two positive integers N, M. The following M lines each contains two integers u, v, meaning there is a two-way road between town u and v. The roads are numbered from 1 to M according to the order of the input.

    The input will be terminated by EOF.

    输出

    Description

    One day, Tom traveled to a country named BGM. BGM is a small country, but there are N ( N ≤ 100 ) towns in it. Each town products one kind of food, the food will be transported to all the towns. In addition, the trucks will always take the shortest way. There are M ( M ≤ 3000 ) two-way roads connecting the towns, and the length of the road is 1.

    Let SUM be the total distance of the shortest paths between all pairs of the towns. Please write a program to calculate the new SUM after one of the M roads is destroyed.

    Input

    The input contains several test cases.

    The first line contains two positive integers N, M. The following M lines each contains two integers u, v, meaning there is a two-way road between town u and v. The roads are numbered from 1 to M according to the order of the input.

    The input will be terminated by EOF.

    Output

    Output M lines, the i-th line is the new SUM after the i-th road is destroyed. If the towns are not connected after the i-th road is destroyed, please output "INF" in the i-th line.

    Sample Input

    5 4
    5 1
    1 3
    3 2
    5 4
    2 2
    1 2
    1 2

    Sample Output

    INF
    INF
    INF
    INF
    2
    2

    Source

    样例输入

    5 4
    5 1
    1 3
    3 2
    5 4
    2 2
    1 2
    1 2

    样例输出

    INF
    INF
    INF
    INF
    2
    2

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部