Burrows

Problem #349

Tags: c-1 graphs popular-algorithm

Who solved this?

No translations... yet

Thanks a lot to Mathias Kern for this new chapter from the life of Easter Bunnies!

Naturally, Easter bunnies live in burrows. Each bunny has its own burrow, and some burrows are connected via tunnels. There are N=555555 bunnies overall – they are numbered from 0 to N-1 – and there are N-1 = 555554 tunnels. It is guaranteed that each burrow can be reached from any other burrow. What is the farthest distance between two burrows, i. e. how many tunnels have to be crossed at most?

Input: A single integer X0 that is used as the seed for the Linear Congruential Generator introduced in the problem 25 - use A=445, C=700001 and M=2097152. Generate N-1 random values r, transform the i-th (i=1,…,N-1) random value via mod i to the range 0 .. (i-1), and let’s call the result r(i). Add a tunnel between the burrows for bunnies r(i) and i.

Output: The farthest distance between two burrows.

Example: For X0=0, the answer is 55.

You need to login to get test data and submit solution.