Delivery robots
Time limit1sMemory limit1024 MB
Given a connected undirected graph, find the largest number of vertices that can lie on simple paths from a chosen start s to a chosen end f.
Problem
Juku likes hot dogs. A lot.
Juku lives in a town with intersections and two-way streets connecting them. The intersections are numbered . No pair of intersections is connected by more than one street, and no street connects an intersection to itself. From every intersection, it is possible to reach every other intersection along the streets. Each intersection has a hot dog stand.
Juku is building delivery robots to bring him hot dogs. He chooses two intersections, the initial location of the robots and his own location , and programs the robots so that he gets hot dogs from as many different stands as possible.
Programming the robots is limited. Each robot can store an array and a variable . A robot starts moving from intersection and repeats these steps:
- If the robot is at intersection , it buys a hot dog from the stand there.
- If the robot is at intersection , it gives the hot dog to Juku and stops.
- The robot moves to intersection , where is its current location.
For every , there must be a street between intersections and . Otherwise the robot crashes.
Find the maximum number of different stands Juku can get hot dogs from, when he chooses and optimally and enters and into the robots optimally. The values and are the same for all robots, but and can differ for each robot. You may assume Juku can use arbitrarily many robots.
Input
The first line contains two integers and , the number of intersections and the number of streets (, ). Each of the next lines contains two integers and , meaning there is a street between intersections and .
Output
Print a single integer: the maximum number of different stands Juku can get hot dogs from.