上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 24 下一页
摘要: 由于已经给出字符只有NC种,故可以把子串视为一个NC进制的数,以此构造hash函数就可以了 1 #include <set> 2 #include <map> 3 #include <cmath> 4 #include <queue> 5 #include <vector> 6 #include < 阅读全文
posted @ 2020-02-11 19:25 墨鳌 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 哈希,对于每个点哈希一次 哈希的方式:该点到联通分量边界(上下左右)的距离和 然后分别对两个图的n个点按hash值排序,判断是否相等即可 1 #include <set> 2 #include <map> 3 #include <cmath> 4 #include <queue> 5 #includ 阅读全文
posted @ 2020-02-11 13:43 墨鳌 阅读(174) 评论(0) 推荐(0) 编辑
摘要: /* 虽然题目没说,但是读入有以下特点 由于,输入是按照按照y递增,如果y相同则x递增的顺序给出的 所以,可以利用入读的时间进行降为处理 */ 于是我们就得到了一个一维的树状数组解法啦 值得一提:坐标从0~32000,而树状数组是从1开始的 于是,我们对所有下标+1,数组开到32002就可以啦! 1 阅读全文
posted @ 2020-02-10 19:27 墨鳌 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 二维树状数组+叉分 区间修改转化为单点修改 单点查询本来就可视为区间查询 于是本题可解 PS:不知道为什么函数传参数,传的是变量就会出现奇奇怪怪的问题? 所以读入单独写了,还有就是循环的初始化硬是多定义了一组变量,头大啊! 暂且把这种写法视为标准写法吧! #include <set> #includ 阅读全文
posted @ 2020-02-10 13:41 墨鳌 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 给出0~n-1的一个排列,可以整体移动,求逆序对最小值 把数字num[i]的加入,等价于树状数组的第n-num[i]位加1 因为num[i]是第 (n-1)-num[i]+1=n-num[i]大的数字,产生逆序对,只可能在其之前已经插入了数字,此时直接区间查询即可 #include <set> #i 阅读全文
posted @ 2020-02-10 00:53 墨鳌 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 树上的单点修改+子树查询 用dfn[u]和num[u]可以把任意子树表示成一段连续区间,此时结合树状数组就好了 #include <set> #include <map> #include <cmath> #include <queue> #include <vector> #include <cs 阅读全文
posted @ 2020-02-09 20:44 墨鳌 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 单点修改+区间查询=树状数组 空间复杂度O(n) 时间复杂度O(mlogn) 1 #include <set> 2 #include <map> 3 #include <cmath> 4 #include <queue> 5 #include <vector> 6 #include <cstdio> 阅读全文
posted @ 2020-02-09 19:27 墨鳌 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 时间复杂度O(n) 空间复杂度O(1) 1 #include <cstdio> 2 int main() { 3 int T;scanf("%d",&T); 4 for(int t=1,n,a,l,r,s,L,R,S;t<=T;t++) { 5 scanf("%d",&n),l=L=R=1; 6 f 阅读全文
posted @ 2020-02-08 15:07 墨鳌 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 1 #include <cstdio> 2 int main(){ 3 for(int a,b;~scanf("%d%d",&a,&b);printf("%d\n",a+b)); 4 return 0; 5 } hdu1000 1 #include <cstdio> 2 int main(){ 3 阅读全文
posted @ 2020-02-08 13:26 墨鳌 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 题意: 求数字11212312341234512345612345671234567812345678912345678910123456789101112345678910111212345678910111213...的第i位是几? 数位dp打表+二分+暴力模拟 0msAC哦!暴力美学! 1 # 阅读全文
posted @ 2020-02-07 20:11 墨鳌 阅读(184) 评论(0) 推荐(0) 编辑
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 24 下一页