The bugged computer chip. While working on a sorting algorithm, you discover a big problem! The computer chip you are using has a rare but infamous bug, called Broken Arithmetic Primary Comparison: the chip compares floating-point numbers with an offset. To be precise, given two numbers $$$x$$$ and $$$y$$$, the comparison checks whether $$$x-1 \lt y$$$. You want to know whether you can still sort a list of numbers.
Hidden from you is a sequence of $$$n$$$ distinct floating-point values $$$a_1, a_2, \ldots, a_n$$$. You are given a list of all $$$m$$$ pairs $$$(i,j)$$$ with $$$i\neq j$$$ for which $$$a_i-1 \lt a_j$$$. Based on this information, can the sequence be unambiguously sorted?
The hidden sequences that the samples are based on, respectively, are $$$a=[0.9,1.1]$$$, $$$a=[4,2]$$$, and $$$a=[1.7,1,2.5]$$$.
The input consists of:
If the order of the sequence is unambiguously determined, output the indices such that the values are in increasing order. Otherwise, output "ambiguous".
2 2 1 2 2 1
ambiguous
2 1 2 1
2 1
3 5 3 1 1 2 2 3 2 1 1 3
2 1 3
| Name |
|---|


