
Bitset优化
文章平均质量分 71
做不完的ACM
加油,努力
展开
-
Hihocoder1513
#include using namespace std;#define rank rank_const int N = 30007;int s[N][5], rank[N][5];bitsetb[5][N];int main(){ //std::ios::sync_with_stdio(false), cin.tie(nullptr), co原创 2018-01-10 11:57:12 · 225 阅读 · 0 评论 -
ACM 位运算
转载至:http://blog.youkuaiyun.com/mtrix/article/details/61200302给集合里的元素一个顺序,那么就可以用整数表示集合,某一位为1表示对应元素被选取。 设x为表示集合的整数,那么这个整数有如下性质: x的子集整数y在数值上不会比x大。因为x的子集y只是保留了x某些位置上的1,所以y总可以加上一个非负的转载 2018-01-29 16:15:41 · 273 阅读 · 0 评论 -
bitset复习
题目:求子集的算术和的异或和题解:按照正常思路是维护一个dp[i],表示和为i的组合有多少个,然后如果dp[i]%2==1则ans^i就可以了··然而复杂度为sum*n,果断T考虑用一个布尔数组表示dp[i],dp[i]为1表示和为i的组合的数量为奇数,0为偶数然后每输入一个数x,可以用dp[i]更新dp[i+x],即dp[i+x]=(dp[i+x]+dp[i])%2,既然我们用的是布尔数组,可以...原创 2018-03-08 00:38:58 · 167 阅读 · 0 评论 -
BITSET里的用法
引用:http://blog.youkuaiyun.com/tri_integral/article/details/11098033用法:1.初始化:bitset<标记数组大小> 数组名称(初始值,二进制的比如0xffff)默认所有位都是0any():有一位为1就返回1none():所有位都为0返回1count():返回1的个数set(n):第n位置1set():全部置1reset(n):第n位...原创 2018-03-08 00:39:53 · 202 阅读 · 0 评论 -
CodeForces333E Summer Earnings
题目链接:http://codeforces.com/contest/333/problem/E题面:Many schoolchildren look for a job for the summer, and one day, when Gerald was still a schoolboy, he also decided to work in the summer. But as Gera...原创 2018-03-08 22:45:52 · 286 阅读 · 0 评论 -
牛客练习赛14D bitset最短路
链接:https://www.nowcoder.com/acm/contest/82/E来源:牛客网题目描述 有一个n个点的无向图,有m次查询,每次查询给出一些(xi,yi) 令dist(x,y)表示x和y点在图中最短距离,dist(x,x)=0,如果x,y不连通则dist(x,y) = inf 每次查询图中有多少个点v与至少一个这次询问给出的(xi,yi)满足dist(v,xi...原创 2018-04-01 18:51:11 · 177 阅读 · 0 评论 -
SPOJ:Harbinger vs Sciencepal(分配问题&不错的DP&bitset优化)
题目链接:https://vjudge.net/problem/SPOJ-R6PLRainbow 6 is a very popular game in colleges. There are 2 teams, each having some members and the 2 teams play some matches against each other. The team which ...原创 2018-04-24 12:23:48 · 198 阅读 · 0 评论 -
SPOJ:Ada and Orange Tree (LCA+Bitset)
题目链接:https://vjudge.net/problem/SPOJ-ADAORANGAda the Ladybug lives near an orange tree. Instead of reading books, she investigates the oranges. The oranges on orange tree can be in up to 5*50 Shades o...原创 2018-04-24 19:21:15 · 304 阅读 · 0 评论 -
Codeforces981E
题目链接:http://codeforces.com/contest/981/problem/E题意:给出若干个操作,问任意选出这些操作的子集,最大值的在1-n的有多少种可能。题解:那就是我其实只需要最后去看一下能否凑成即可 不需要考虑是否是最大 因为在选择的时候我们可以任选子集 可以尝试 好一个数通过好多次加法之后他不是最大的 那么一定构造不出。直接在线段树是跑bitset即可,复杂度(N*Lo...原创 2018-06-01 00:59:58 · 413 阅读 · 0 评论