시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB28211872.000%

문제

Many are familiar with the board game Ticket To Ride (Ticket To Ride is copyrighted by Days of Wonder, Inc.) where players compete to build a railway empire, claiming routes between cities. The game consists of a map of cities and various rail segments each connecting two adjacent cities. 

A key way to score points towards winning the game is to complete Destination Tickets.  Each ticket specifies two distinct cities. A player earns the points that are indicated on the ticket if they have claimed one or more rail segments that form a path connecting the two cities.

There is one ticket for each distinct unordered pair of cities. In our version of the game, each player is randomly given a ticket and they have an equal probability of receiving any ticket. Given a list of rail segments you have already claimed, determine the probability you earn points from the ticket you are given.

입력

The first line of input contains two integers $N$ ($2 \leq N \leq 10^5$), which is the number of cities, and $M$ ($0 \leq M \leq 10^6$), which is the number of rail segments you have claimed.

The next $M$ lines describe your claimed rail segments. Each line contains two distinct integers $i$ ($1 \leq i \leq N$) and $j$ ($1 \leq j \leq N$), which are the cities that this rail segment connects.

출력

Display the probability you earn points from the ticket you are given.

Your answer should have an absolute error of at most $10^{-6}$.

예제 입력 1

4 2
1 2
3 4

예제 출력 1

0.33333333333333333333

예제 입력 2

5 4
1 5
2 3
2 4
3 4

예제 출력 2

0.4

예제 입력 3

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

예제 출력 3

0.42857142857142857143

출처

ICPC > Regionals > North America > Rocky Mountain Regional > 2021 Rocky Mountain Regional Contest L번

  • 문제를 만든 사람: Ryan Farrell