Days have passed since their wedding, and Touko has by one way or another failed to remember which date the wedding was and what was the first marking a! Expecting that Yuu may blow up, Touko chose to request you to get these two pieces from data utilizing the current marking. Being her old buddy, you wanted to track down the number of days that have passed since the
Correct answer will be upvoted else downvoted. Computer science.
Days have passed since their wedding, and Touko has by one way or another failed to remember which date the wedding was and what was the first marking a! Expecting that Yuu may blow up, Touko chose to request you to get these two pieces from data utilizing the current marking.
Being her old buddy, you wanted to track down the number of days that have passed since the wedding, and the first naming of the tree. Notwithstanding, quite possibly Touko may have wrecked her methods, which bring about the current naming being difficult to get from some unique marking; all things considered, kindly illuminate Touko also.
Input
The main line of the input contains an integer n (2≤n≤3⋅105) — the number of hubs on the tree.
The subsequent line contains n integers a1, a2, ..., an (1≤
Each of the following n−1 lines contains two integers ui and vi (1≤u,v≤n, u≠v), portraying a coordinated edge from ui to vi. The edges structure a coordinated tree established at 1.
Output
On the off chance that the current naming is difficult to show up at from any DFS request, print NO.
Else, on the main line, print YES. On the subsequent line, print a solitary integer indicating the number of days since the wedding. On the third line, print n numbers space-isolated indicating the first naming of the tree.
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 4 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)