XOR MST
Time limit2sMemory limit512 MB
Given N labeled vertices where the edge between any two has weight equal to the XOR of their labels, find the total cost of the minimum spanning tree.
- Level
Hard8 of 10
- Topics
- Trie, Minimum spanning tree, Divide and conquer, Bit manipulation
- Solved
- No attempts yet
Problem
There is an undirected graph with vertices. The -th vertex is labeled with an integer . The weight of the edge connecting vertex and vertex is .
Find the cost of the minimum spanning tree (MST) of this graph.
Input
The first line gives the number of vertices . The second line gives .
Output
Print the cost of the MST on the first line.