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

Разделы > Linear Data Structures: Arrays > задача:


51099 - Mr. Monk

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

Задачи раздела

• 50444 - n digit kth number divisible...
• 50865 - Apartment Building Adminis...
• 51089 - Multiply a row and add it to ...
• 50874 - Apartment Building Adminis...
• 50531 - File Decryption
• 51012 - Palindrome-k
• 50469 - Letter Grades
• 50525 - Ordering Pizza
• 51099 - Mr. Monk
• 50468 - Draw Matrix - 2
• 51096 - Guess the number - 2
• 50448 - Paint Buckets
• 50988 - Laplacian Filter
• 50269 - Matrix Determinant
• 50986 - The Oldest Person
• 50925 - Optimizing Elevator Usage
• 51173 Question 5

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

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

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

Mr Monk

Mr Monk is a detective who has Obsessive Compulsive Disorder (OCD). He cannot stand if there is something untidy. He has to put them in order.

Question: Now, he wants to put the numbers in a 2D array in order. But there are k cells which he cannot move. Help him and put the numbers in order whitout moving the cells in the given positions.

Input specification: Firstly, you will be given two integers (n and m) size of 2D array. Then, you will be given m integers in the following n lines. Next line, you will be given an integer (k): the number of blocked cells. In the following k lines you will be given the (x,y) coordinates of k numbers where 1 ≤ (n and m) ≤ 100; 1 ≤ k ≤ 10,000; and the numbers in the matrix are less 10,001

Output specification: Show the new sorted matrix (sorted matrix including the blocked cells).

Sample Input I Sample Input II
4 3
7 9 17
9 14 12
6 11 7
13 15 5
2
1 3
3 1
5 3
19 8 6
7 13 16
8 4 11
5 20 20
20 5 14
3
3 2
2 3
2 5
Sample Output I Sample Output II
5 7 17
7 9 9
6 11 12
13 14 15
5 6 7
8 8 16
11 4 13
14 19 20
20 5 20



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

www.contester.ru