上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 25 下一页
摘要: 区间众数先离散化,学到了lagoon的lower_bound+unique的离散化,比我写的简单多了预处理分成sqrt(n)块,记录d[i][j]和p[i][j]分别表示从i块起始位置到j块终止位置的众数出现次数和这个数是谁开一个数组,记录每个数的位置,使得同类的相邻,同类数的坐标升序排列。对于询问:对于同一块内或者相邻块内的,直接暴力。对于不同块内的,统计出非整块的区间内的所有出现过的数字,然后对这些数字在二分存储位置的数组,统计块内这个数出现的次数。然后结合d[i][j]和p[i][j]就可以得出答案了View Code 1 #include <iostream> 2 #inc 阅读全文
posted @ 2013-01-17 20:08 proverbs 阅读(1027) 评论(0) 推荐(0) 编辑
摘要: 能够支持动态插入的东西很容易想到splay。然后就是树上的hash了。。悲剧的我没找到哪里错了。。。果断70分wa。。。错误代码(思想是正确的):View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <algorithm> 6 7 #define N 1000000 8 9 using namespace std; 10 11 char str[N]; 12 int sz[N],s 阅读全文
posted @ 2013-01-17 19:58 proverbs 阅读(831) 评论(1) 推荐(1) 编辑
摘要: 单调队列是递减的,储存的是递减的元素的位置。然后询问的时候就在单调队列里面二分地寻找合适的最大值所在的位置最近二分总是写不对。不知道怎么了。。。以前从来没出过错。。。View Code 1 #include <iostream> 2 #include <cstdlib> 3 #include <cstdio> 4 #include <cstring> 5 #include <algorithm> 6 7 #define N 1000000 8 #define INF 0x3f3f3f3f 9 10 using namespace st 阅读全文
posted @ 2013-01-17 19:55 proverbs 阅读(602) 评论(0) 推荐(0) 编辑
摘要: 这题其实不是很难,就是我没写对。。把情况想全了:有很多个连通块(单向边看作双向边),对于每个连通块有这样几类情况:1、2、3、应该就是这几类吧~现在先讨论最大值第1类:对答案没有影响第2类:环上的点数一定是答案的倍数第3类:两个链的长度的差一定是答案的倍数所以答案就是2、3的最大公约数(有2、3存在的情况下)综上所述,先计算第1类,再就算2、3类。。ps:我是一起做的,然后长跪不起了,最后抄的lyd神犇的。。。有个技巧,就是把边权设为1和-1~View Code 1 #include <iostream> 2 #include <cstdio> 3 #include & 阅读全文
posted @ 2013-01-17 19:52 proverbs 阅读(1632) 评论(0) 推荐(0) 编辑
摘要: 暴力递推,转化成通项公式,利用补集法求解~注意负数情况。。。好久不写快速幂了,竟然没写错~View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <algorithm> 5 #include <cstdlib> 6 7 #define mod 100003 8 9 using namespace std;10 11 long long n,m;12 13 inline long long pow(long long a,lo 阅读全文
posted @ 2013-01-17 19:35 proverbs 阅读(379) 评论(0) 推荐(0) 编辑
摘要: 环形均分纸牌,数学推导不是很难。只给提示:设p[i]表示第i个人给第i+1个人的纸牌数,若p[i]<0表示,第i+1个人给第i个人的纸牌数然后自己推吧~View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cstdio> 5 #include <algorithm> 6 #include <cmath> 7 8 #define N 2000000 9 10 using namespace std;11 阅读全文
posted @ 2013-01-17 19:32 proverbs 阅读(1164) 评论(0) 推荐(0) 编辑
摘要: 看数据范围特别小,然后就暴力dp就好了~还要想清楚,选择的路径,一定是某一天的最短路!View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <cstdlib> 5 #include <algorithm> 6 7 #define N 200 8 #define M 100000 9 10 using namespace std;11 12 int head[N],next[M],to[M],len[M];13 int ca 阅读全文
posted @ 2013-01-17 19:29 proverbs 阅读(1128) 评论(0) 推荐(0) 编辑
摘要: 这题简直太神了,我才知道网络流还可以这样做!这题想了近一个小时构图,没搞出来。。最后看了BYvoid大神的题解搞得。。http://www.byvoid.com/blog/noi-2008-employee/无限仰慕!View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <algorithm> 6 7 #define N 2000 8 #define M 200000 9 #def 阅读全文
posted @ 2013-01-15 13:36 proverbs 阅读(809) 评论(0) 推荐(0) 编辑
摘要: 时间复杂度(渐近时间复杂度的严格定义,NP问题,时间复杂度的分析方法,主定理)排序算法(平方排序算法的应用,Shell排序,快速排序,归并排序,时间复杂度下界,三种线性时间排序,外部排序)数论(整除,集合论,关系,素数,进位制,辗转相除,扩展的辗转相除,同余运算,解线性同余方程,中国剩余定理)指针(链表,搜索判重,邻接表,开散列,二叉树的表示,多叉树的表示)按位运算(and,or,xor,shl,shr,一些应用)图论(图论模型的建立,平面图,欧拉公式与五色定理,求强连通分量,求割点和桥,欧拉回路,AOV问题,AOE问题,最小生成树的三种算法,最短路的三种算法,标号法,差分约束系统,验证二分图 阅读全文
posted @ 2013-01-15 10:43 proverbs 阅读(2503) 评论(0) 推荐(0) 编辑
摘要: Splay写的真是抑郁,各种被坑。。。被题坑,被自己坑。一直在调程序。。。Splay模板:View Code 1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 #include <cstdlib> 5 #include <cstdio> 6 7 #define N 170000 8 #define INF 2e9 9 10 using namespace std; 11 12 int son[N][2],fa[N],val[N],sum[N]; 13 阅读全文
posted @ 2013-01-15 10:29 proverbs 阅读(2825) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 25 下一页