HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Unsorted > problem:


50489 - Football Championship

Section problems

• 50281 - Primes
• 50287 - Providers
• 50476 - Meditation
• 50879 - Passed or Failed
• 50428 - Three Times
• 50387 - Passengers in the Train
• 50391 - Cinema Tickets
• 50402 - Hello World!
• 50489 - Football Championship
• 51004 - Word Search Game
• 50430 - ATM
• 50426 - Calculating Sales
• 50425 - Calculating Weekly Pay
• 50438 - Pattern with stars
• 50820 - Post Office
• 50810 - Print Office
• 50952 - Derby Tirana

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