They say that Berland has exactly two problems, fools and roads. Besides, Berland has n cities, populated by the fools and connected by the roads. All Berland roads are bidirectional. As there are many fools in Berland, between each pair of cities th…
To your surprise, Jamie is the final boss! Ehehehe. Jamie has given you a tree with n vertices, numbered from 1 to n. Initially, the root of the tree is the vertex with number 1. Also, each vertex has a value on it. Jamie also gives you three types o…
Misha and Grisha are funny boys, so they like to use new underground. The underground has n stations connected with n - 1 routes so that each route connects two stations, and it is possible to reach every station from any other. The boys decided to h…
Housewife Wind http://poj.org/problem?id=2763 Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 14820 Accepted: 4097 Description After their royal wedding, Jiajia and Wind hid away in XX Village, to enjoy their ordinary happy life. Peopl…
Battle over Cities Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 467 Accepted Submission(s): 125 Problem Description It is vitally important to have all the cities connected by highways in…
Codeforces Round #329 (Div. 2) D. Happy Tree Party time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Bogdan has a birthday today and mom gave him a tree consisting of n vertecies. For every…