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

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


15-MdtE-3. 50913 - Manhattan Distance

CEN112 Questions 2016

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

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

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

• 15-FE-7. 50990 - Two Neighbors
• 15-FE-8. 50991 - Intersecting Circles
• 15-HW-2. 50932 - Shifting rows and...
• 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 ...
• 15-MdtE-4. 50917 - Descending Nu...
• 15-MdtE-5. 50912 - Trip to Librazhd
• 15-MdtE-6. 50914 - Buy 3, Pay 2
• 15-PE-1. 50865 - Apartment Building...
• 15-PE-2. 50866 - Buy the cheapest
• 15-PE-4. 50868 - Sort Frequencies
• 15-PE-5. 50869 - Birthday Celebration
• 15-PE-7. 50871 - Harmonic Mean

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

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

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

Manhattan Distance

Question: In a grid like shape, Manhattan distance is the sum of vertical and horizontal straight line distance. You will be given a point and the IDs and (x, y) coordinates of n other points. Then, you will be given the IDs of k points to process. Find the total Manhattan distance for all k points from the given point.

Input specification
You will be first given the (x, y) coordinate of a point. Then, you will be given two numbers: the number of all points (n) and the number of points to process (k). The following n lines will have three numbers ID and x, y coordinates of n points. In the last line, you will be given k numbers (IDs of k points to process) where 0 ≤ k ≤ n ≤ 10,000. and the coordinates are integers between -2e4 and 2e4.

Output specification:
Show one integer number: total Manhattan distance.

Sample Input I
5 8 8 4
3 9 10
8 1 6
11 8 2
15 10 8
17 9 7
18 7 3
21 4 6
22 8 1
3
8
15
18

Sample Output I
24

Explanation: The coordinate of the checkpoint is (5,8). There are 8 points given and k= 4. The following 8 lines, contain the ID and coordinates of 8 points. Then, we are given IDs of k points to process. Manhattan distance of:

  • point 3 is: 6 (9-5) + (10-8)
  • point 8 is: 6 (5-1) + (8-6)
  • point 15 is: 5
  • point 18 is: 7
Thus, the total distance is 24.



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

www.contester.ru