Izhevsk Training Camp
Time limit3sMemory limit256 MB
Given nine contests, each a ranking of n teams, pick three contests so that the number of team pairs ordered the same way in all three is minimized.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Brute force, Sorting, Combinatorics
- Solved
- No attempts yet
Problem
The Izhevsk Training Camp is about to begin. This season, teams numbered with consecutive integers from to will take part in the event. Nine contests will be offered to the participating teams over a period of eleven days. The contests are numbered with consecutive integers from to . Three of these contests will form the Udmurtia Head Super Cup (UHSC). The question is: which three contests should be chosen for the UHSC?
Oleg helps run the Izhevsk Training Camp. For any contest, he knows in advance what place each of the teams will take. He wants to use this knowledge to select three contests so that the total boredom of the UHSC is minimized.
The boredom of the UHSC is the number of pairs of teams {, } such that team beat team in each of the three UHSC contests.
Write a program that helps Oleg find three contests , , and for the UHSC such that the total boredom of the UHSC is as small as possible.
Input
The first line of the input contains an integer , the number of participating teams ().
The -th of the following nine lines contains the description of the -th contest: distinct positive integers from to , the team numbers ordered from first place to last.
Output
The only line of the output should contain three positive integers , , and , the numbers of the contests chosen for the UHSC (, , , ).
If there are several correct answers, output any of them.
Hint
For the sample test, the minimum possible value of boredom is .