PivotOJ

Making Friends

시간 제한: 3000ms메모리 제한: 1024MB출처: USACO 2022 December PlatinumBOJ 26967

문제

There are initially MM (1M21051\le M\le 2\cdot 10^5) pairs of friends among FJ's NN (2N21052\le N\le 2\cdot 10^5) cows labeled 1N1\dots N. The cows are leaving the farm for vacation one by one. On day ii, the ii-th cow leaves the farm, and all pairs of the ii-th cow's friends still present on the farm become friends. How many new friendships are formed in total?

입력

The first line contains NN and MM.

The next MM lines contain two integers uiu_i and viv_i denoting that cows uiu_i and viv_i are friends (1ui,viN1\le u_i,v_i\le N, uiviu_i\neq v_i). No unordered pair of cows appears more than once.

출력

One line containing the total number of new friendships formed. Do not include pairs of cows that were already friends at the beginning.

힌트

On day 11, three new friendships are formed: (3,4)(3,4), (3,7)(3,7), and (4,7)(4,7).

On day 33, two new friendships are formed: (4,5)(4,5) and (5,7)(5,7).

예제

예제 1

입력
7 6
1 3
1 4
7 1
2 3
2 4
3 5
출력
5
코드를 제출하려면 로그인하세요.