#P4252. Maximal Tourist Route

    ID: 17499 Type: Default 1000ms 256MiB

Maximal Tourist Route

Maximal Tourist Route

You are given an undirected graph representing M city's attractions. The city has \(n\) attractions numbered from 1 to \(n\) and there are \(m\) two-way roads connecting them. A tourist guide wants to plan a tour such that the group visits as many distinct attractions as possible. The route may start and end at any attraction, but no attraction is allowed to be visited more than once.

Your task is to compute the maximum number of attractions that can be visited in a simple path (i.e. a path without repeating vertices).

Input Format: The first line contains two integers \(n\) and \(m\) representing the number of attractions and roads respectively. The following \(m\) lines each contain two integers \(u\) and \(v\) indicating that there is a bi-directional road between attractions \(u\) and \(v\).

Output Format: Output a single integer denoting the maximum number of attractions that can be visited along any valid route.

Note: \(n\) is small enough to allow an exhaustive search solution.

inputFormat

The first line contains two integers \(n\) and \(m\), the number of attractions and the number of roads, respectively.

The next \(m\) lines each contain two integers \(u\) and \(v\) indicating a road connecting attraction \(u\) and attraction \(v\).

\(1 \leq u, v \leq n\)

outputFormat

Output a single integer: the maximum number of attractions that can be visited in a simple path.

sample

1 0
1