HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Albanian National Olympiads in Informatics > problem:


2015-2. 50489 - Football Championship

Volume problems

• 2012-4. 50680 - Triangle
• 2012-5. 50551 - Camelot
• 2013-1. 50591 - Leap year
• 2013-3. 50570 - Prime numbers in t...
• 2013-4. 50958 - ATM
• 2013-5. 50543 - Hotel rooms
• 2013-6. 50562 - List of students
• 2014-2. 50738 - Median value
• 2015-2. 50489 - Football Champ...

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Translated by Muhamed Keta.

Football Championship

Question: In a certain football championship there are n teams. Every season, every team has a match with any other team exactly once. A season consists of $n - 1$ turns. It’s a way of doing things for a team not to have two consecutive matches in the same place (home, or away). Frankly this isn’t always possible. They didn’t have any idea what to do so they sought your help to minimize the number of consecutive times every squad plays at the same position, and give them a possible calendar for their next championship.

Input specification
A number n, denoting the number of teams playing where 2 ≤ n ≤ 1000; and n is even

Output specification
On the first line, show the minimum number of matches the squads can play consecutively on different positions. On the next n - 1 lines show any possible calendar which satisfies the previously calculated number. Each line consists of n/2 pairs of numbers 1...n, denoting the teams. Each of these pairs of form (u, v) means that team U, plays home and team V plays away.

Sample Input I   
2
Sample Input II   
4
Sample Output I   
0
1 2
Sample Output II   
2
1 2 3 4
1 4 2 3
1 3 4 2


Äëÿ îòïðàâêè ðåøåíèé íåîáõîäèìî âûïîëíèòü âõîä.

www.contester.ru