Map Generator Returns (MG-II)
Time limit1sMemory limit128 MB
Given N places and independent edge probability P, find the probability that the random graph on N vertices is connected.
- Level
Medium7 of 10
- Topics
- Probability, Dynamic programming, Combinatorics, Graph
- Solved
- No attempts yet
Problem
You have just finished your research on the FAMI algorithm (see the earlier task “Map Generator”). You are very proud of yourself and even expect a bonus this month. Your boss, whose nickname is Dean, asks you to come to his office for a moment. You expect thanks and even a promotion. But…
“What is this?” asks Dean, showing you your latest report.
“Well, um, these are the results of my FAMI algorithm research…” you answer. It seems that your dreams of a promotion soon are… just dreams. Yet you still do not understand what is wrong with your report.
“I can read, by the way,” Dean continues. “I am talking about the absolute error. Why is it so big? I require better results!”
When you argue with your boss, the best argument is silence. So now, instead of a bonus and a promotion, you need to rewrite your program.
The FAMI algorithm builds a map as follows. The map has places. For each unordered pair of two distinct places (there are such pairs), FAMI independently, with probability , builds a two-way road connecting them. The generated map is connected if you can travel between every pair of places using roads only. Find the probability that FAMI generates a connected map.
Input
The input consists of two lines. The first line contains an integer (). The second line contains a real number ().
Output
Print, on a single line, the probability that FAMI generates a connected map, rounded to exactly digits after the decimal point.