线性基
线性基
不哭的超人
愿你孤独的努力终有回报,愿你前行的路上有人相伴。
展开
-
P3857 [TJOI2008]彩灯
P3857 [TJOI2008]彩灯 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double lf; typedef pair<int,int>P; const int inf = 0x7f7f7f7f; const double INF = 1e16; const int N = 2e6+10; const ll mod = 77797; const double原创 2021-01-28 16:21:55 · 53 阅读 · 0 评论 -
P3812 【模板】线性基
P3812 【模板】线性基 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double lf; typedef pair<int,int>P; const int inf = 0x7f7f7f7f; const double INF = 1e16; const int N = 1e3+10; const ll mod = 100000000; const double P原创 2021-01-28 16:20:22 · 68 阅读 · 0 评论 -
P4151 [WC2011]最大XOR和路径
P4151 [WC2011]最大XOR和路径 解题思路:该图从任何一点都可以获取一个环的异或值。先求出一条1~n简单路径的异或值。通过dfs求出所有环的值。 ans=一条路径+环。 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double lf; typedef unsigned long long ull; typedef pair<int,int>P; const原创 2021-01-28 16:07:58 · 101 阅读 · 0 评论 -
Mahmoud and Ehab and yet another xor task
Mahmoud and Ehab and yet another xor task 解题思路:先离线处理,按照l从小到大排序。然后依次将a数组中的数插入到线性基中,如果个数达到了l,判断x是否可以由线性基中的数异或得到。如果能那么答案就是2l-cnt,l表示已经插入了多少个数,cnt表示线性基中有几个非0的数。 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double lf; ty原创 2021-01-25 00:32:30 · 125 阅读 · 0 评论 -
P4570 [BJWC2011]元素
P4570 [BJWC2011]元素 解题思路:线性基。线性基里的任意几个元素相异或是不会得到0的。先将输入的元素按照价值从大到小排序。然后依次的往线性基中插入序号。如果能成功插入,则可以加上这个元素的价值,否则就不加上,应该可能序号相异或为0; #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double lf; typedef pair<int,int>P; const原创 2021-01-25 00:27:13 · 59 阅读 · 0 评论