#P2610. Maximizing City Visits in T Country
Maximizing City Visits in T Country
Maximizing City Visits in T Country
During the rare summer vacation, in celebration of Xiao Bai's excellent score in math, Xiao Lan decided to take Xiao Bai on a trip. They chose country T as their destination. The territory of T can be represented by a convex n-gon, whose n vertices are the entry/exit points. T contains \(n-2\) cities; each city is a triangle whose vertices are among the vertices of the n-gon (in other words, the cities form a triangulation of T).
The travel route is a line segment connecting two non-adjacent vertices of the n-gon. To get the best souvenirs, Xiao Bai wishes the route to pass through as many cities as possible. As a friend of Xiao Lan, your task is to help determine the maximum number of cities (triangles) that a travel route can pass through.
Explanation
Consider any diagonal connecting two non‐adjacent vertices. If the segment is not one of the edges of the triangulation it will cross the interior of a sequence of adjacent cities. It can be shown that the optimal route will cross exactly \( \lfloor n/2 \rfloor \) cities.
For example, in a quadrilateral (n=4) the optimal route passes through 2 cities, and in a hexagon (n=6) it passes through 3 cities.
inputFormat
The input consists of a single integer \(n\) (with \(n \ge 4\)), representing the number of vertices of the convex polygon (T country's border).
outputFormat
Output a single integer: the maximum number of cities (triangles) that can be passed through by an optimal travel route. The answer is given by \(\lfloor n/2 \rfloor\).
sample
4
2