Fruit Weights
Time limit1sMemory limit128 MB
Given inequalities between multiples of unknown fruit weights, decide if the query, its reverse, both, or neither must hold, or the givens contradict.
- Level
Medium7 of 10
- Topics
- Shortest path, Graph
- Solved
- No attempts yet
Problem
Compare fruits by weight. In this problem every fruit of the same kind is identical and weighs the same, and every weight is positive.
One comparison is written as , where and are positive integers and and are fruit names. It says that fruits of type weigh no more than fruits of type .
Given several such comparisons, decide the result of one more comparison.
Input
The input holds several test cases. The first line of each test case has , the number of given comparisons. Each of the next lines has one comparison in the form a X b Y, which means . The last line of the test case has a query in the same form a X b Y, and you compare with .
A line with marks the end of the input and is not processed. Apart from that final , every integer in the input is positive and at most 100. Fruit names are case sensitive strings of lowercase and uppercase letters with length at most 50.
Output
Print one line per test case. For a query a X b Y the result is one of the following.
<=: you are sure that .>=: you are sure that .==: you are sure that , that is, you reached both of the two results above.UNAVAILABLE: you can say nothing for sure about and , that is, you reached none of the three results above.INCONSISTENT: the given comparisons contradict one another, that is, you are sure they cannot all hold at the same time.
When the comparisons contradict one another, print INCONSISTENT rather than any other result.