DFS-B - Dr. Evil Underscores】的更多相关文章

B - Dr. Evil Underscores Today, as a friendship gift, Bakry gave Badawy nn integers a1,a2,…,ana1,a2,…,an and challenged him to choose an integer XX such that the value max1≤i≤n(ai⊕X)max1≤i≤n(ai⊕X) is minimum possible, where ⊕⊕ denotes the bitwise XOR…
CF1285 --- Dr. Evil Underscores 题干 Today as a friendship gift, Bakry gave Badawy \(n\) integers \(a_1,a_2, \cdots ,a_n\) and challenged him to choose an integer \(X\) such that the value \(\mathop{max}\limits_{1\leq i\leq n}(a_i \oplus X)\) is minimu…
挂个链接 Description: 给你 \(n\) 个数 \(a_1,a_2,--,a_n\) ,让你找出一个 \(x\) ,使 \(x\) 分别异或每一个数后得到的 \(n\) 个结果的最大值最小. Solution: 设 \(x\) 为题中所说, \(m\) 为 \(max{x^a_i}\) : 构建 \(01Trie\) ,将所有数的二进制形式存到 \(01Trie\) 上,对于第 \(k\) 位,存在两种情况: 一是都是0或都是1,这样只要使 \(x\) 的第 \(k\) 位为1或0,…
题目大意:n个数,任意整数x对这n个数取异或值,然后使最大值最小. 思路:数据范围最大为pow(2,30);所以考虑二进制的话,最多有30位.对于某一位d,然后考虑数组v中每一个元素的d为是0还是1,将为0的元素放到数组v0中,将为1的元素放到数组v1中.如果v0中的元素个数为0,那么说明这一位置上的元素全为1,所以我们贪心地希望x在该位置上的为1,对于V1同理.如果说v1和v0都不等于0,那么说明x在该位置与其他元素做异或运算,肯定会有1,所以答案为为两种情况的最小值+1<<d. ACcod…
链接:https://codeforces.com/problemset/problem/1285/D 题意:给n个数a1,a2,a3.....an,找到一个数X,使得X 异或所有的ai ,得到的max(X xor ai)最小,输出这个值. 思路:a的范围是0~230,我们可以以01二进制的形式建一棵深度为30的字典树,每个数ai 的二进制序列插入到字典树中去,例如5 = 101,那么101按位插入到字典树中去.然后从根开始遍历,在字典树上dp,因为该字典树建完后是一棵二叉树,所以分支情况就两种…
目录: 1.1093D. Beautiful Graph(DFS染色) 2.514C - Watto and Mechanism(Tire) 3.69E.Subsegments(STL) 4.25C. Roads in Berland(最短路松弛操作) 5.128B. String Problem (floyd预处理) 6.33C.Wonderful Randomized Sum(思维) 7.1292B.Aroma's Search (暴力+思维) 8.1286 A.Garland(DP) 9.…
contest链接:https://codeforces.com/contest/1285 A. Mezo Playing Zoma 签到 #include<iostream> #include<vector> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<queue> #include<map>…
Mahmoud and Ehab continue their adventures! As everybody in the evil land knows, Dr. Evil likes bipartite graphs, especially trees. A tree is a connected acyclic graph. A bipartite graph is a graph, whose vertices can be partitioned into 2 sets in su…
                              The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous…
HDU 1241 题目大意:给定一块油田,求其连通块的数目.上下左右斜对角相邻的@属于同一个连通块. 解题思路:对每一个@进行dfs遍历并标记访问状态,一次dfs可以访问一个连通块,最后统计数量. /* HDU 1241 Oil Deposits --- 入门DFS */ #include <cstdio> int m, n; //n行m列 ][]; /* 将和i,j同处于一个连通块的字符标记出来 */ void dfs(int i, int j){ || j < || i >=…