CF1787E The Harmonization of XOR 题解】的更多相关文章

https://www.lydsy.com/JudgeOnline/problem.php?id=2115 https://www.luogu.org/problemnew/show/P4151 这道题当年还是新题,现在都成线性基套路题了. 参考:https://blog.sengxian.com/algorithms/linear-basis 一个1~n路径值可以拆成一条1~n的路径值^几个环(因为去到环和回来的路的值被异或回去了). 于是就变成了处理出所有环的异或值和所有1~n的无环路的异或…
http://acm.hdu.edu.cn/showproblem.php?pid=3949 求n个数的异或和第k小. 参考:https://blog.sengxian.com/algorithms/linear-basis 没了. #include<cstdio> #include<iostream> #include<cstring> #include<vector> #include<algorithm> using namespace s…
目录 题目链接 题解 代码 题目链接 HDU 3949 XOR 题解 hdu3949XOR 搞死消元找到一组线性无关组 消出对角矩阵后 对于k二进制拆分 对于每列只有有一个1的,显然可以用k的二进制数直接异或得到第k大 对于一列由多个1的,由于二进制性质,由于2的幂+1次方比2的(1到幂)的和要大,所以不影响大小 代码 #include<queue> #include<cstdio> #include<cstring> #include<algorithm>…
题目链接:http://codeforces.com/contest/742/problem/B B. Arpa's obvious problem and Mehrdad's terrible solution time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are some beautiful girls in…
+++++++++++++++++++++++++++++++++++++++++++ +本文作者:luyouqi233. + +欢迎访问我的博客:http://www.cnblogs.com/luyouqi233/+ +++++++++++++++++++++++++++++++++++++++++++ —————————————————————————————————————————— http://www.lydsy.com/JudgeOnline/problem.php?id=2337…
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output Bob has a favorite number k and ai of length n. Now he asks you to answer m queries. Each query is given by a pair li and ri and asks you to cou…
刚学了LCA,写篇题解巩固一下 首先题目有误: (A是否是男生 )xor( B是否是男生)=A和B是否能够成为情侣,这句话显然是错误的qwq 对于这道题,容易看出,对于待处理的两个点,只要我们找到他的最近公共祖先,问题便游刃而解了 所以我的思路就是:lca+xor前缀和 这是我的大法师函数 yihuo数组就是保存当前节点到根节点的xor值 推算了一下,对于xor前缀和有: 两个点x,y间的的xor值=yihuo[x]^yihuo[y] void dfs(int f,int father,int…
[WC2011]最大XOR和路径 给一个 \(n\) 个点 \(m\) 条边(权值为 \(d_i\))的无向有权图,可能有重边和子环.可以多次经过一条边,求 \(1\to n\) 的路径的最大边权异或和. 数据范围:\(1\le n\le 5\cdot 10^4\),\(1\le m\le 10^5,0\le d_i\le 10^{18}\). 非常神的一题,令小蒟蒻大开眼界. 一句话题解:通过 \(\texttt{Dfs}\) 得到到每个点的一种路径答案,用线性基找到最优替换方案. 先看这个奇…
Mahmoud and Ehab and yet another xor task 存在的元素的方案数都是一样的, 啊, 我好菜啊. 离线之后用线性基取check存不存在,然后计算答案. #include<bits/stdc++.h> #define LL long long #define LD long double #define ull unsigned long long #define fi first #define se second #define mk make_pair…
bzoj2115,戳我戳我 Solution: 看得题解(逃,我太菜了,想不出这种做法 那么丢个链接 Attention: 板子别写错了 又写错了这次 \(long long\)是左移63位,多了会溢出就会出鬼 Code: //It is coded by Ning_Mew on 5.29 #include<bits/stdc++.h> #define LL long long using namespace std; const int maxn=5e4+7,maxm=1e5+7; int…