#1371
Unrated
Distance Sum
시간 제한
4s
메모리 제한
512MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

You are given a connected undirected unweighted graph. The distance d(u,v)d(u, v) between two vertices uu and vv is defined as the number of edges in the shortest path between them. Find the sum of d(u,v)d(u, v) over all unordered pairs (u,v)(u, v).

입력

The first line of the input contains two integers nn and mm (2n1052 \le n \le 10^5; n1mn+42n - 1 \le m \le n + 42) — the number of vertices and the number of edges in the graph respectively. The vertices are numbered from 1 to nn.

Each of the following mm lines contains two integers xix_i and yiy_i (1xi,yin1 \le x_i, y_i \le n; xiyix_i \ne y_i) — the endpoints of the ii-th edge.

There is at most one edge between every pair of vertices.

출력

Output a single integer — the sum of the distances between all unordered pairs of vertices in the graph.

예제 입력 1

4 4
1 2
2 3
3 1
3 4

예제 출력 1

8

예제 입력 2

7 10
1 2
2 6
5 3
5 4
5 7
3 6
1 7
5 1
7 4
4 1

예제 출력 2

34

노트

In the first example the distance between four pairs of vertices connected by an edge is equal to 1 and d(1,4)=d(2,4)=2d(1, 4) = d(2, 4) = 2.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.