Problem: In certain sports leagues, the n participating teams are ranked from 1 to n at the end of the season. Suppose you are given access to a time machine (TM) that can help you figure out what the rankings will be in your favorite sports league at the end of the upcoming season. You can ask a question to the time machine in the form of a complete ranking of all the teams. The TM either tells you that the ranking in your question is correct, or hands you a pair of teams that are in flipped order in the correct ranking. Design an algorithm to find the correct ranking with O(n^2) such questions to this TM.