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

Турниры > CEN112 Questions 2016 > задача:


15-HW-2. 50932 - Shifting rows and columns

CEN112 Questions 2016

Старт: 30.мар.2016 в 15:10:22
Финиш: 01.апр.2016 в 05:00:00
Турнир завершён!
• Турнирная таблица

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

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

• 15-FE-1. 50992 - Top K Obese Classes
• 15-FE-2. 50993 - Products in store
• 15-FE-3. 50994 - The Most Crowded...
• 15-FE-4. 50995 - Group Average
• 15-FE-6. 50989 - Rectangles and Points
• 15-FE-7. 50990 - Two Neighbors
• 15-FE-8. 50991 - Intersecting Circles
• 15-HW-2. 50932 - Shifting rows ...
• 15-HW-3. 50933 - Sum of the Bigges...
• 15-HW-4. 50934 - Selling Cars
• 15-HW-5. 50935 - Max Discount
• 15-MdtE-1. 50915 - Trip to Korca
• 15-MdtE-2. 50916 - Ascending Num...
• 15-MdtE-3. 50913 - Manhattan Distance
• 15-MdtE-4. 50917 - Descending Nu...
• 15-MdtE-5. 50912 - Trip to Librazhd

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

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

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

Shifting Rows and Columns

You are given a two dimensional (nxn) array. Assume that the rows and columns are numbered from 1 to n. Then, you are given k instructions which include 3 components:

  • Direction: R (Right), L (Left), U (Up), D (Down)
  • Shifting row or column number
  • The number of shifts
If you are given the instruction R 3 2: it means you need to shift the third row 2 cells right. When shifting numbers, 0 is inserted to the beginning of row or column. And, the last 2 numbers which go out of border is omitted.

Question: Write a program that takes an array and k instructions. The program prints the sum of the numbers in the array after following the instructions.

Input specification
You will be given an integer (n) the size of 2D array. Then, you will have n numbers in each of the following n lines. The next line contains an integer (k), the number of instructions. And, the following k lines will contain k instructions where 0 ≤ n ≤ 80 and 0 ≤ k ≤ 2,000.

Output specification:
Show sum of the numbers in the array.

Sample Input I
4
1 6 1 0
6 9 0 2
2 6 2 8
5 3 1 1
3
R 3 1
U 2 2
D 3 1
Sample Output I
29



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

www.contester.ru