forked from hackerearthclub/CODE2RACE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Bishu and his Girlfriend | ||
|
||
There are N countries {1,2,3,4....N} and N-1 roads(i.e depicting a tree) | ||
|
||
Bishu lives in the Country 1 so this can be considered as the root of the tree. | ||
|
||
Now there are Q girls who lives in various countries (not equal to 1) . | ||
|
||
All of them want to propose Bishu.But Bishu has some condition. | ||
|
||
He will accept the proposal of the girl who lives at minimum distance from his country. | ||
|
||
Now the distance between two countries is the number of roads between them. | ||
|
||
If two or more girls are at the same minimum distance then he will accept the proposal of the girl who lives in a country with minimum id. | ||
|
||
No two girls are at same country. | ||
|
||
Input: First line consists of N,i.e number of countries Next N-1 lines follow the type u v which denotes there is a road between u and v. Next line consists of Q Next Q lines consists of x where the girls live. | ||
|
||
Output: Print the id of the country of the girl who will be accepted. | ||
|
||
Help Him!!!!! | ||
|
||
contraints: 2<=N<=1000 1<=u,v<=N 1<=Q<=(N-1) | ||
|
||
-------------------------------------------------------- | ||
Author: https://www.hackerearth.com/@satishgpta007 |