上一页 1 ··· 5 6 7 8 9 10 11 12 下一页
摘要: #前言 均使用unsigned long long溢出自动取模; 非unsigned long long版本:OI-wiki 字符串hash #详解 #模板 ##预处理进制B的次方 void init_bp(){ bp[0][0] = bp[1][0] = 1; for(int i=1;i<=hs; 阅读全文
posted @ 2021-03-16 15:46 棉被sunlie 阅读(110) 评论(0) 推荐(0)
摘要: 题链 题意求区间最长连续子序列最大和 当数据存在负数时,不能单纯取三个地方的max,如: p[rt].maxn = max(p[ls].rmax+p[rs].lmax,max(p[rt].lmax,p[rt].rmax)); #include <bits/stdc++.h> #include <io 阅读全文
posted @ 2021-03-16 13:34 棉被sunlie 阅读(49) 评论(0) 推荐(0)
摘要: 题链 该题洛谷题解区讲的都很好; 当询问时, l == r时,答案有可能不是true... (奇怪的坑) #include <bits/stdc++.h> #include <iostream> #include <algorithm> #include <stdio.h> #include <st 阅读全文
posted @ 2021-03-16 11:02 棉被sunlie 阅读(62) 评论(0) 推荐(0)
摘要: 题链 对于mark的引入: 如果不引入直接加,会出现某段区间被重复加的现象,要保证若某段区间被覆盖,则只需要加一次。 #include <bits/stdc++.h> #include <iostream> #include <algorithm> #include <stdio.h> #inclu 阅读全文
posted @ 2021-03-15 22:09 棉被sunlie 阅读(95) 评论(0) 推荐(0)
摘要: CSDN syddf_shadow 阅读全文
posted @ 2021-03-15 20:55 棉被sunlie 阅读(25) 评论(0) 推荐(0)
摘要: 题链 边带权并查集,val[i]记录编号为i的舰船距离根舰船的距离,合并时如x接到y所在舰队的末尾,fx,fy为x,y的根节点,并不是val[fx] += val[y],这里的若不是真正舰队末尾则出错,需要sum[i]数组记录某一列舰队的数目,val[fx] += sum[fy]; 具体如代码着重部 阅读全文
posted @ 2021-03-15 20:53 棉被sunlie 阅读(53) 评论(0) 推荐(0)
摘要: 题链 若要将一个排列转换成另一个排列,一次只能交换相邻两个元素,例如将 a = {4, 3, 1, 2} 变成 b = {1, 3, 2, 4},最少需要交换 a或b 几步; 新建 pa[a[i]] = i 记录排名a[i]的位置,pb[b[i]] = i 记录排名b[i]的位置,令p[pa[i]] 阅读全文
posted @ 2021-03-15 17:55 棉被sunlie 阅读(58) 评论(0) 推荐(0)
摘要: OI-Wiki #include <bits/stdc++.h> #include <iostream> #include <algorithm> #include <stdio.h> #include <string.h> #include <stdlib.h> //#pragma GCC opt 阅读全文
posted @ 2021-03-14 10:52 棉被sunlie 阅读(58) 评论(0) 推荐(0)
摘要: 重定义的时候就如写sort时的cmp一样,最后将return时候的">","<"反过来就行 #include <bits/stdc++.h> #include <iostream> #include <algorithm> #include <stdio.h> #include <string.h> 阅读全文
posted @ 2021-03-14 00:47 棉被sunlie 阅读(109) 评论(0) 推荐(0)
摘要: 题链 贪心把使用优惠劵后价格前K个一一压入队列(以队列 QQ 表示)直到钱不够(可以证明前K个是一定要买的,因为最赚),其他未被压入队列的价格压入队列 Q 例如价格前K个中某个产品以原价购买+后K个某个产品以优惠价购买也是可行的情况 2 1 5 2 1 1000 3 则 QQ队列中以原价和优惠价的差 阅读全文
posted @ 2021-03-14 00:41 棉被sunlie 阅读(74) 评论(1) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 下一页