https://codeforces.com/contest/888/problem/G 这题可以用Boruvka算法: 一开始每个点是一个连通块.每次迭代对于每个连通块找到其最近邻居(与其有边相连且与其间最短边最短的连通块),然后将每个连通块和其最近邻居合并(选择的边自然是两连通块间最短边).直到只剩一个连通块.考虑每一次迭代,连通块个数至少减半,因此只会进行O(log n)次迭代.边权有相等时可能需要一些特判 摘自wikipedia: Cut property For any cut C o…
You are given a complete undirected graph with n vertices. A number ai is assigned to each vertex, and the weight of an edge between vertices i and j is equal to ai xor aj. Calculate the weight of the minimum spanning tree in this graph. 题目大意: 边权为两端点…
Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers x1, x2, ..., xk (k > 1) is such maximum element xj, that the following inequality holds: . The lucky number of the seque…
*注意:这套题目应版权方要求,不得公示题面. 从这里开始 Problem A XOR Problem B GCD Problem C SEG 表示十分怀疑出题人水平,C题数据和标程都是错的.有原题,差评. Problem A XOR 题目大意 最小异或生成树 出门左拐Codeforces 888G. Code #include <iostream> #include <cstdlib> #include <cstdio> #include <vector>…
题目链接: http://codeforces.com/problemset/problem/242/E E. XOR on Segment time limit per test 4 secondsmemory limit per test 256 megabytes 问题描述 You've got an array a, consisting of n integers a1, a2, ..., an. You are allowed to perform two operations on…
题目链接:http://codeforces.com/problemset/problem/627/A 题意: 告诉你s 和 x,a + b = s a xor b = x a, b > 0. 让你求符合条件的a b有多少对 思路: a + b = s , a ^ b = x ==> s - x = (a & b) * 2 #include <bits/stdc++.h> using namespace std; typedef long long LL;…