#B4143. Minimum Station Count on a Circular Metro Line
Minimum Station Count on a Circular Metro Line
Minimum Station Count on a Circular Metro Line
A new circular metro line has been built in city L. The line consists of n stations numbered in the ascending order 1, 2, \(\cdots\), n along the clockwise direction. Unlike conventional metro lines, a circular metro line does not have a clear starting or ending station, and its directions are defined differently.
On regular lines, the train direction may be described as "towards Station A" or "towards Station B." However, on a circular line, the directions are specified as "inner" and "outer". Following the regulations similar to Beijing's metro network, in this problem, the inner designation corresponds to the train running in the clockwise direction, while outer corresponds to the train running in the counterclockwise direction.
Given the total number of stations n, and starting station x and destination station y, determine whether taking the inner (clockwise) train or the outer (counterclockwise) train will pass through fewer stations. In case both directions pass through the same number of stations, choose inner.
The number of stations passed is calculated as follows:
Let \(d_{cw} = \begin{cases} y - x, & y \ge x \\ n - (x - y), & y < x \end{cases}\) denote the number of stations passed when moving in the clockwise (inner) direction. The counterclockwise (outer) distance is \(d_{ccw} = n - d_{cw}\). Your task is to determine the optimal direction.
inputFormat
The input consists of a single line containing three integers n, x, and y (\(1 \le x, y \le n \le 10^9\)), where:
- n is the total number of stations on the circular metro line.
- x is the starting station.
- y is the destination station.
outputFormat
Output a single string, either inner
or outer
, representing the direction that passes through the fewer number of stations. If the number of stations passed in both directions is equal, output inner
.
sample
10 2 5
inner