#P3469. [POI2008] BLO-Blockade

[POI2008] BLO-Blockade

题目描述

There are exactly nn towns in Byteotia.

Some towns are connected by bidirectional roads.

There are no crossroads outside towns, though there may be bridges, tunnels and flyovers. Each pair of towns may be connected by at most one direct road. One can get from any town to any other-directly or indirectly.

Each town has exactly one citizen.

For that reason the citizens suffer from loneliness.

It turns out that each citizen would like to pay a visit to every other citizen (in his host's hometown), and do it exactly once. So exactly n(n1)n\cdot (n-1) visits should take place.

That's right, should.

Unfortunately, a general strike of programmers, who demand an emergency purchase of software, is under way.

As an act of protest, the programmers plan to block one town of Byteotia, preventing entering it, leaving it, and even passing through.

As we speak, they are debating which town to choose so that the consequences are most severe.

Task Write a programme that:

reads the Byteotian road system's description from the standard input, for each town determines, how many visits could take place if this town were not blocked by programmers, writes out the outcome to the standard output.

给定一张无向图,求每个点被封锁之后有多少个有序点对(x,y)(x!=y,1<=x,y<=n)满足x无法到达y

输入格式

In the first line of the standard input there are two positive integers: nn and mm (1n100 0001\le n\le 100\ 000, 1m500 0001\le m\le 500\ 000) denoting the number of towns and roads, respectively.

The towns are numbered from 1 to nn.

The following mm lines contain descriptions of the roads.

Each line contains two integers aa and bb (1a<bn1\le a<b\le n) and denotes a direct road between towns numbered aa and bb.

输出格式

Your programme should write out exactly nn integers to the standard output, one number per line. The ithi^{th} line should contain the number of visits that could not take place if the programmers blocked the town no. ii.

题目大意

B 城有 nn 个城镇,mm 条双向道路。

每条道路连结两个不同的城镇,没有重复的道路,所有城镇连通。

把城镇看作节点,把道路看作边,容易发现,整个城市构成了一个无向图。

请你对于每个节点 ii 求出,把与节点 ii 关联的所有边去掉以后(不去掉节点 ii 本身),无向图有多少个有序点 (x,y)(x,y),满足 xxyy 不连通。

【输入格式】

第一行包含两个整数 nnmm

接下来 mm 行,每行包含两个整数 aabb,表示城镇 aabb 之间存在一条道路。

【输出格式】

输出共 nn 行,每行输出一个整数。

ii 行输出的整数表示把与节点 ii 关联的所有边去掉以后(不去掉节点 ii 本身),无向图有多少个有序点 (x,y)(x,y),满足 xxyy 不连通。

【数据范围】

n100000n\le 100000m500000m\le500000

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

8
8
16
14
8