문제
Note: the time limit for this problem is 3s, 50% larger than the default. The memory limit is twice the default.
There are initially () pairs of friends among FJ's () cows labeled . The cows are leaving the farm for vacation one by one. On day , the -th cow leaves the farm, and all pairs of the -th cow's friends still present on the farm become friends. How many new friendships are formed in total?
입력
The first line contains and .
The next lines contain two integers and denoting that cows and are friends (, ). 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.
예제 입력 1
7 6
1 3
1 4
7 1
2 3
2 4
3 5
예제 출력 1
5
점수
Test cases 2-3 satisfy .Test cases 4-7 satisfy .Test cases 8-17 satisfy no additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인