need help coding this in C language. Problem Given the employee's traversal of the park, and the exhibits that the visitors want to visit determine how many unique monkeys the visitor will see on their way from the entrance to the exhibit and then back. Input Input will begin with a line containing 1 integer, n (1 ≤ n ≤ 200,000), representing the number of exhibitsin the park (including the entrance). The following line contains 2 integers, i and m (i = 1; 1 ≤ m ≤ 5,000), representing the ID of the entrance and the number of monkeys at the entrance. Each of the following 2n - 2 lines will contain a path description recorded by our employee. If this is the

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need help coding this in C language.

Problem

Given the employee's traversal of the park, and the exhibits that the visitors want to visit determine how
many unique monkeys the visitor will see on their way from the entrance to the exhibit and then back.

Input

Input will begin with a line containing 1 integer, n (1 ≤ n ≤ 200,000), representing the number of exhibitsin the park (including the entrance). The following line contains 2 integers, i and m (i = 1; 1 ≤ m ≤ 5,000), representing the ID of the entrance and the number of monkeys at the entrance. Each of the following 2n - 2 lines will contain a path description recorded by our employee. If this is the first time the employee used the path, then the line will contain two integers, i and m (2 ≤ i ≤ n; 1 ≤ m ≤ 5,000), representing the ID of the destination exhibit and the monkeys at the destination exhibit respectively. If this is the second time the path is used, then the line will contain the integer -1 instead, since the ID and number of monkeys were already recorded. You can assume that the monkeys don’t move between exhibits. The following line contains a single integer, v (1 ≤ v ≤ 500,000), representing the number of visitors to the park. The following v lines will each contain a single integer, e (1 ≤ e ≤ n), representing the ID of the exhibit that the guest is going to visit.

Output

Output should contain v lines. Each line will contain a corresponding integer representing the number of
unique monkeys seen in the corresponding visitor’s park visit. The order of the output should correspond
to the order of the input.

**Sample Input**

```
4
1 10
2 13
4 25
-1
3 6
-1
-1
3
4
3
2
```

**Sample Output**

```
48
29
23
```

This table presents a sample input-output set commonly used in programming problems. 

- The first set of numbers under "Sample Input" starts with a single number, 4, which could represent the number of subsequent data groups or cases.
- Following that are pairs of numbers and single numbers. Each line has a specific meaning or operation that leads to the values shown in the "Sample Output."
- When graphed or visualized, each output correlates to a set of computations derived from the "Sample Input" according to the problem's logic.
Transcribed Image Text:**Sample Input** ``` 4 1 10 2 13 4 25 -1 3 6 -1 -1 3 4 3 2 ``` **Sample Output** ``` 48 29 23 ``` This table presents a sample input-output set commonly used in programming problems. - The first set of numbers under "Sample Input" starts with a single number, 4, which could represent the number of subsequent data groups or cases. - Following that are pairs of numbers and single numbers. Each line has a specific meaning or operation that leads to the values shown in the "Sample Output." - When graphed or visualized, each output correlates to a set of computations derived from the "Sample Input" according to the problem's logic.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education