DCP-466: Sanvi and TreeMap Back to All Problems

Easy Beginners Problems > Ad-hoc


**Sanvi** is a very cute girl. She wants to travel different cities around the world. Recently, She has got a map with a list of cities where she is interested to visit including her current city. Different cities are numbered from **1** to **5**, which are: 1. Dhaka 2. Chittagong 3. Rajshahi 4. Kathmandu 5. Butwal And, Map looks like below: ![enter image description here][1] The above map's structure looks like [Tree data structure][2] in computer science. The node representing each city and edge representing connection between two cities and distance between them.<br> Currently Sanvi is staying in one of the above city and she wants to travel to any one of above city( destination city). Your task is to find the total distance she needs to travel to reach the destination city. Input: ------ Input starts with an integer **Q (1<=Q<=20)**, denoting the number of Quires.<br> Each query contains two city names separated by a space between them. City name will be exactly one of the above mentioned city. Output: ------- For each query output the total distance she needs to travel in a single line. Sample Input ------------ 2 Dhaka Butwal Kathmandu Dhaka Sample Output ------------- 8200 3200 [1]: https://s3-ap-southeast-1.amazonaws.com/devskillimagestorage/questionimages/7a6e9cdf-6a59-cb00-1c52-08d54e9de865_a9974d6bf167466ebbea7c7f8321024f_W416xH307.png [2]: https://en.wikipedia.org/wiki/Tree_%28data_structure%29


Problem Setter:

Bishal Gautam

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 2.00
Go 2.00
Java 2.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats

162/314

Solve/Submission

Ranking

# User Language Timing
01 mobasshir Cpp14 0.00s
02 iqHpi Cpp 0.00s
03 shawon100 Cpp 0.00s
04 Puja1409 Cpp14 0.00s
05 badhansen123 Cpp 0.00s
06 subhashis_cse Cpp 0.00s
07 Zayed Cpp 0.00s
08 Durbin Cpp14 0.00s
09 shamimjucse Cpp 0.00s
10 t0whid Cpp 0.00s
11 robin_aust Cpp 0.00s
12 saiful130104 Cpp 0.00s
13 MRITuhin Cpp 0.00s
14 _zErO_ Cpp 0.00s
15 prodipdatta7 Cpp 0.00s
16 shahincsejnu Cpp 0.00s
17 shishir09 Cpp14 0.00s
18 mhiceiuk Cpp 0.00s
19 haasib Cpp 0.00s
20 Jisancse Cpp14 0.00s
21 sherina Cpp 0.00s
22 tariqiitju Cpp 0.00s
23 The_Viper Cpp 0.00s
24 Shamim_A Cpp 0.00s
25 rayhan50001 Cpp 0.00s
26 yasirnabil534 Cpp 0.00s
27 Logic_Hunter Cpp14 0.00s
28 non_coder Cpp 0.00s
29 Suhi31 Cpp 0.00s
30 Brokenlog Cpp 0.00s
31 iamsadee Cpp 0.00s
32 CodeHunger18 Cpp 0.00s
33 AbirRahman Cpp 0.00s
34 Sagor Cpp 0.00s
35 afzalul C 0.00s
36 the_badcoder Cpp 0.00s
37 motaleb_ICT Cpp 0.00s
38 csesabbir Cpp 0.00s
39 Sarwar05 Cpp 0.00s
40 prottoy919 Cpp 0.00s
41 _GhOstMan_ Cpp 0.00s
42 bu_hridoy Cpp 0.00s
43 Sheikh_Fahad Cpp 0.00s
44 Islam_Rafat Cpp14 0.00s
45 Sajal_Deb Cpp 0.00s
46 Dhrubo020 Cpp 0.00s
47 Taran Cpp14 0.00s
48 srijonsbzsifat Cpp 0.00s
49 IIUC_minhazmiraz Cpp14 0.00s
50 Tanmoy Cpp 0.00s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support