Rockethon 2014

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
391 Rockethon 2014 FINISHED False 10800 383832023 Feb. 16, 2014, 6 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 186 ) E2 Three Trees PROGRAMMING

This problem consists of two subproblems: for solving subproblem E1 you will receive 11 points, and for solving subproblem E2 you will receive 13 points. A tree is an undirected connected graph containing no cycles. The distance between two nodes in an unweighted tree is the minimum number of edges that have to be traversed to get from one node to another. You are given 3 trees that have to be united into a single tree by adding two edges between these trees. Each of these edges can connect any pair of nodes from two trees. After the trees are connected, the distances between all unordered pairs of nodes in the united tree should be computed. What is the maximum possible value of the sum of these distances? The first line contains three space-separated integers n 1 , n 2 , n 3 — the number of vertices in the first, second, and third trees, respectively. The following n 1 - 1 lines describe the first tree. Each of these lines describes an edge in the first tree and contains a pair of integers separated by a single space — the numeric labels of vertices connected by the edge. The following n 2 - 1 lines describe the second tree in the same fashion, and the n 3 - 1 lines after that similarly describe the third tree. The vertices in each tree are numbered with consecutive integers starting with 1 . The problem consists of two subproblems. The subproblems have different constraints on the input. You will get some score for the correct submission of the subproblem. The description of the subproblems follows. In subproblem E1 (11 points), the number of vertices in each tree will be between 1 and 1000 , inclusive. In subproblem E2 (13 points), the number of vertices in each tree will be between 1 and 100000 , inclusive. Print a single integer number — the maximum possible sum of distances between all pairs of nodes in the united tree. Consider the first test case. There are two trees composed of two nodes, and one tree with three nodes. The maximum possible answer

Tutorials

Submissions

No solutions yet.