CF645D Robot Rapping Results Report
Description
While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as possible. When she covers the 2016 Robot Rap Battle Tournament, she notices that all of the robots operate under deterministic algorithms. In particular, robot $ i $ will beat robot $ j $ if and only if robot $ i $ has a higher skill level than robot $ j $ . And if robot $ i $ beats robot $ j $ and robot $ j $ beats robot $ k $ , then robot $ i $ will beat robot $ k $ . Since rapping is such a subtle art, two robots can never have the same skill level.
Given the results of the rap battles in the order in which they were played, determine the minimum number of first rap battles that needed to take place before Bessie could order all of the robots by skill level.
Input Format
N/A
Output Format
N/A
Explanation/Hint
In the first sample, the robots from strongest to weakest must be $ (4,2,1,3) $ , which Bessie can deduce after knowing the results of the first four rap battles.
In the second sample, both $ (1,3,2) $ and $ (3,1,2) $ are possible orderings of the robots from strongest to weakest after both rap battles.