CF888G.Xor-MST
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a complete undirected graph with n vertices. A number a__i is assigned to each vertex, and the weight of an edge between vertices i and j is equal to a__i xor a__j.
Calculate the weight of the minimum spanning tree in this graph.
给你一个包含 n 个顶点的完全无向图。每个顶点 i 被赋予一个数 ai,顶点 i 与顶点 j 之间边的权重等于 ai⊕aj。
请计算该图的最小生成树(MST)的总权重。
输入格式
The first line contains n (1 ≤ n ≤ 200000) — the number of vertices in the graph.
The second line contains n integers _a_1, _a_2, ..., a__n (0 ≤ a__i < 230) — the numbers assigned to the vertices.
第一行包含一个整数 n(1≤n≤200000)—— 图中顶点的数量。
第二行包含 n 个整数 a1,a2,…,an(0≤ai<230)—— 分配给各顶点的数值。
输出格式
Print one number — the weight of the minimum spanning tree in the graph.
输出一个数字——该图的最小生成树的权重。
输入输出样例
输入#1
5 1 2 3 4 5
输出#1
8
输入#2
4 1 2 3 4
输出#2
8
输入解题思路,AI测评打分。不知道怎么写?