Robot Race
Time limit2sMemory limit256 MB
For each polygonal path, decide whether the straight-line distance to any later point never increases along the walk.
- Level
Medium7 of 10
- Topics
- Geometry, Brute force
- Solved
- No attempts yet
Problem
Robots race along a path that the organizing committee fixes in advance. Every robot starts at the first point of the path, follows the path without leaving it, and stops at the last point.
One point of the path holds a charging station. Every robot carries a device that reports the straight-line distance from the robot to the station. The device does not report the distance that is left along the path.
Some robots run buggy control software. A buggy robot reads the number on its device as the distance left along the path, so it expects that number to keep getting smaller until it reaches the station. The moment the number gets larger, the robot decides that it has already passed the station without charging, and it crashes.
Let be the position of a robot at time , and let be the straight-line distance between two points and . A path is unfair if the station can be placed at some point of the path so that a buggy robot crashes on the way, that is, if there are three times such that the robot is at the station at time and
A path that is not unfair is fair. The committee has a list of candidate paths and wants to know which of them are fair. Decide for each given path whether it is fair.
Input
The input holds several test cases. The first line of each test case holds an integer (), the number of points of the path. Each of the next lines holds two integers and (, ), the coordinates of one point. The -th of those lines gives the -th point of the path. A robot starts at the first point, walks the segments joining consecutive points one after another, and stops at the last point. The path does not intersect itself. The input ends with a line that holds a single 0, and that line is not a test case.
Output
For each test case, print one line. Print Fair if the path is fair, and Unfair if it is not.