ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Турниры > IMPC-2014-15 Questions > задача:


Ind_04-20. 50520 - Filling a Matrix Randomly

IMPC-2014-15 Questions

Старт: 22.ноя.2014 в 15:00:00
Финиш: 22.ноя.2014 в 20:00:00
Турнир завершён!
• Турнирная таблица

Гость
• Вопросы к жюри (1)

Задачи турнира

• Ind_02-10. 50497 - Falling Bricks - ...
• Ind_02-20. 50745 - Bitonic Sequence
• Ind_02-30. 50657 - Permutations an...
• Ind_03-10. 50743 - Total Scholarshi...
• Ind_03-20. 50515 - Lines - Revisited
• Ind_03-40. 50777 - Dwarfs Maze
• Ind_03-50. 50679 - Jetpack Hurdle J...
• Ind_04-10. 50787 - Expected Value
• Ind_04-20. 50520 - Filling a Ma...
• Ind_04-30. 50658 - The Message

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Filling a Matrix Randomly

Your physics professor, wants to analyze the effect of a random variable on a range. For that he wants fill a range with random colors in such a way that no adjacent two cells (4 sides: Up, Down, Right, Left) will have the same colors.

Question: Write a program that is going to fill a range with the given number of colors complying the given condition above.

Input specification
You will be given only three integers:

  • The number of rows (m) for the given range
  • The number of cols (n) for the given range
  • The number of colors (c) where you can use the colors from 1 to c
where m and n are integers between 0 and 500, and c is an integer between 1 and 100.

Output specification
If possible, fill the given shape with the given colors randomly. Show -1, if it's not possible to fill comply the given criterion. Note: All the colors have to be used at least once.

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


Для отправки решений необходимо выполнить вход.

www.contester.ru