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

Турниры > CEN303_2016Questions > задача:


HW062. 51021 - Number of Nodes

CEN303_2016Questions

Старт: 28.окт.2016 в 17:00:00
Финиш: 01.ноя.2016 в 05:00:00
Турнир завершён!
• Турнирная таблица

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

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

• HW022. 51012 - Palindrome-k
• HW023. 50741 - DNA Distance
• HW031. 51015 - Student Scholarships
• HW032. 51014 - Nine Men's Morris g...
• HW033. 50925 - Optimizing Elevator...
• HW051. 51019 - Finding the hidden...
• HW052. 51020 - Number of nodes r...
• HW061. 50448 - Paint Buckets
• HW062. 51021 - Number of Nodes
• HW071. 51042 - The most frequent ...
• HW072. 51043 - Genome Sequencing
• HW081. 51044 - Number of Trees
• HW082. 50699 - Fighting Vampires
• HW083. 50671 - Phalanx
• HW091. 51061 - The Longest Path
• HW101. 50682 - Hotel Durres
• HW102. 51067 - Jumping frog

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

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

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

Number of Nodes

Question: Write a program that reads a BST, a node and a direction (Right or Left). Then, the program calculates number of nodes on the given direction of the given node.

Input specification: You will be two integers and a direction in the beginning,

  • number of nodes (n) to be added to the BST,
  • node to be searched in BST
  • the direction: a string which can be only "Right" or "Left"
Each of the following n-lines will have one integer where 0 ≤ n ≤ 40,000 and the numbers are between -5e6 and 5e6. Note: Assume that the BST is initially empty.

Output specification: If the searching number is in the BST, show the number of nodes in the given direction, show zero otherwise.

Sample Input I
7 14 Right
14
10
16
14
19
18
16
Sample Input II
10 18 Left
10
20
18
14
18
12
15
16
12
17
Sample Output I
3
Sample Output II
5



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

www.contester.ru