自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(165)
  • 资源 (2)
  • 收藏
  • 关注

原创 Codeforces Round #197 (Div. 2)(完全)

http://codeforces.com/contest/339/这场正是水题大放送,在家晚上限制,赛后做了虚拟比赛4A,B乱搞水题C 我是贪心过的,枚举一下第一个拿的,然后找使差值最小的那个物品。codeD 裸的线段树,几乎不用思考,push_up函数要注意一下即可codeE 最多三层,暴力搜一下。按以下两个方向搜索

2013-08-31 21:54:02 1070

转载 Splay题库(摘自www.notonlysuccess.com)

【splay入门】用其他平衡二叉树能解决:(理论复杂度没有sbt好,但我用splay却比写sbt还快=.=)[HNOI2002]营业额统计[NOI2004]郁闷的出纳员[HNOI2004]宠物收养所【splay热身】其他平衡二叉树不能解决,但是线段树和splay能解决(效率是线段树的1~5倍.)I Hate It(更新节点,区间最值)A Simple Problem

2013-08-30 23:10:21 1161

原创 hdu 4677 并查集+分块算法 好题 (2013多校联合)

题意:点数n(n ), 边数(m  q(1对于每个询问(l, r),去掉(l,r)区间以外的所有点和其相关联的边,问剩下来的图的联通块的个数。思路:分块+并查集分块算法入门:http://blog.csdn.net/auto_ac/article/details/10050589这题很容易想到分块, 难点是并查集的处理。对询问离线分块排序以后,我们对  左端点在相同块号内的询问

2013-08-30 23:01:33 2200

原创 Codeforces 70D 动态凸包 (极角排序 or 水平序)

题目链接:http://codeforces.com/problemset/problem/70/D本题关键:在log(n)的复杂度内判断点在凸包 或 把点插入凸包判断:平衡树log(n)内选出点所属于的区域插入:平衡树log(n)内选出点所属于的区域, 与做一般凸包的时候类似,分别以该点向左右两边进行维护,一直删除不满足凸包的点,直到所有点满足凸包为止。水平序:

2013-08-30 22:23:31 3371 2

原创 POJ 3233 二分幂+矩阵乘法

无重载View Code #include #include #define maxn 103int n, k, mod;int ret[maxn][maxn], e[maxn][maxn];void mult(int a[maxn][maxn], int b[maxn][maxn]){ int i, j, k; int c[maxn][ma

2013-08-29 10:37:53 844

原创 ZSTU 3194 复数的幂 二分幂

递归View Code #include #include #define LL __int64LL a, b, x, y, mod, n;void gao(LL n, LL &x, LL &y){ if(n == 1) { x = a % mod, y = b % mod; return; }

2013-08-29 10:37:51 847

原创 codeforces 253D 单调队列 好题

View Code #include #include #include using namespace std;char map[404][404];int a[404][404]; int n, m, k, sum;__int64 ans;int cnt[33]; int main(){ freopen("input.txt", "r"

2013-08-29 10:37:49 1278

原创 codeforces 251B Playing with Permutations 模拟

View Code #include#includeint q[103], p[103], s[103], pp[103];int n, k, a, b;int main(){ int i, j; scanf("%d%d", &n, &k); for(i = 1; i ) scanf("%d", &q[i]);

2013-08-29 10:37:46 1143

原创 codeforces 252B Unsorting Array 暴力+贪心

失算啊,水题啊,比赛没AView Code #include#include#includeusing namespace std;int a[100005], b[100005];int main(){ int i, j, n; scanf("%d", &n); for(i = 0; i ) scanf("%d"

2013-08-29 10:37:44 949

原创 codeforces 251A Points on Line 二分 or 单调队列

比赛时我用单调队列A的View Code #include#include#includeusing namespace std;#define LL __int64int a, n, d;LL ans;queue int> q;int main() { int i, j; scanf("%d%d", &n, &d);

2013-08-29 10:37:42 979

原创 HDU 1576 A/B 扩展欧几里德算法 模线性方程入门题

很详细的资料:http://blog.csdn.net/lulipeng_cpp/article/details/7612490补充以下结论,自己推的,解释了以上博客里的疑惑。 方程ax+by=gcd(a,b),即 模线性方程ax≡d(mod b) ,令d = gcd(a,b)。假设 模线性方程的解为 x0, y0。结论1:则有 max( abs(x0),abs(y0) ) 结论2

2013-08-29 10:37:26 942

原创 codeforces div2 #152 小结

这次比赛题目明显较长,自己没耐心读题,心还是太急了。给自己总结了几个缺点:1.心太急,总想侥幸过掉。2.本能觉得有些题目很简单,考虑不充分,没想好思路就敲。3.草稿纸要书写规范,以免重复计算。4.题目长就耐心读题,没什么好抱怨的。5.独立思考能力还不够,总想依赖别人。日后做题要尽量避免这些情况。C题严重考虑错误。View Code #include#

2013-08-29 10:37:17 1110

原创 POJ 3667 Hotel 线段树 区间合并 入门题

View Code #include#includestring.h>#includeusing namespace std;#define maxn 50003#define lson l, m, rt<<1#define rson m+1, r, rt<<1|1#define mid int m = (l + r)>>1int col[maxn2];

2013-08-29 10:37:15 853

原创 POJ 1436 Horizontally Visible Segments 线段树 成段更新

View Code #include#includestring.h>#include#includeusing namespace std;const int maxn = 80001;#define lson l, m, rt<<1#define rson m+1, r, rt<<1|1#define mid int m = (l + r)>>1in

2013-08-29 10:37:12 950

原创 POJ 3225 Help with Intervals 线段树 成段更新

View Code #include#includestring.h>#includeusing namespace std;const int maxn = 656661;#define lson l, m, rt<<1#define rson m+1, r, rt<<1|1#define mid int m = (l + r) >> 1int col[m

2013-08-29 10:37:10 776

原创 POJ 2528 Mayor posters 线段树 成段更新

注意离散化View Code #include#includestring.h>#includeusing namespace std;#define lson l, m, rt<<1#define rson m+1, r, rt<<1|1#define mid int m = (l + r)>>1#define maxn 10004int col[ma

2013-08-29 10:37:08 876

原创 POJ KMP 入门4题

出处:http://blog.csdn.net/lalor/article/details/7358956poj 3461 Oulipo 最简单的KMP题,找出第一个字符串在第二个字符串中出现次数。  View Codepoj 2752 Seek the Name, Seek the Fame 求子串前缀跟后缀一样的各种情况  View Codepoj 2406 Power S

2013-08-29 10:37:06 3341 1

原创 POJ 1952 BUY LOW, BUY LOWER DP 最长下降序列求个数

注意:重复的只算一次如何去掉一些重复的是本题的关键我的去重思路:75 3 7 6 3 2 165 3 7 3 155 3 2 1 3第一组在推到 数字 2 的时候有 3会出现重复, 显然前面一个3是可有可无的。第二组也一样,前面一个3是可有可无的。1.如果最长下降序列中有后面一个3, 如第一二组数据,那么前面一个3是无用的,在推好后面一个3之后把之前的所

2013-08-29 10:37:03 1028

原创 POJ 2479 Maximum sum DP

View Code #include#includestring.h>int a[50003];int f[50003], g[50003];#define inf 1000000000int max(int a, int b) { return a > b ? a : b;}int main(){ int i, j, cas, n; sca

2013-08-29 10:37:01 804

原创 POJ 1157 LITTLE SHOP OF FLOWERS 水DP

注意边界View Code #include#includestring.h>#includeusing namespace std;#define inf 1000000000int max(int a, int b) {return a > b ? a : b;}int n, m;int a[103][103], dp[103][103];int m

2013-08-29 10:36:59 968

原创 POJ 1141 Brackets Sequence 经典区间DP题

记忆化搜索:View Code #include#includestring.h>#includestring>#include#includeusing namespace std;#define inf 1000000000struct node{ int v, vis; // v 表示DP的值,加入的最少的括号个数,vis表示dp这一个状

2013-08-29 10:36:57 927

原创 POJ 1080 Human Gene Functions DP

注意初始化View Code #include#includestring.h>int dp[103][103];char a[103], b[103];int f[7][7];#define inf 1000000000int max(int a, int b, int c){ int x = a > b ? a : b; return

2013-08-29 10:36:54 844

原创 【转】POJ DP 分类

红色表示已经A。打星号的表示个人认为比较经典,或是算法比较好的题目 1014* Dividing    半个背包,注意中断,否则可能TLE1036 Gangsters 可以很水的DP过,还有多种优化的方法1038* Bugs Integrated, Inc.状态压缩1050 To the Max最大子矩形  枚举每个列数为n的矩阵,然后对这些矩阵分别进行DP处理1080

2013-08-29 10:36:52 1563

原创 POJ 1036 Gangsters DP 多解

题意:一群匪徒要进入一个酒店。酒店的门有k+1个状态,每个匪徒的参数是:进入时间,符合的状态,携带的钱。酒店的门刚开始状态0,问最多这个酒店能得到的钱数。 思路1:dp[i][j]表示时间0-i之间,门的状态为j时所能获得的最大利益转移方程 :dp[i][j]=max(dp[i-1][j],dp[i-1][j-1],dp[i-1][j+1]) 因为转移i只跟i-1有关,所以

2013-08-29 10:36:50 842

原创 POJ 1014 Dividing 多重背包

让物体的重量等于价值,用总价值的一半的包去装这些物品,看其是否能装满View Code #include#includestring.h>int dp[120005], a[8];int max(int a, int b) { return a > b ? a : b;}int main(){ int i, j, cas = 1, n, m; w

2013-08-29 10:36:48 736

原创 codeforces 159D dp + strings 好题

关键:很巧妙的枚举思路,枚举回文字符串中间字符的位置i,复杂度O(n),然后统计  以i为起始位置的回文串的个数放在数组p[]中,以末尾位置的回文串的个数放在数组q[]中。最后处理一下即可View Code #include#includestring.h>#define lld __int64char s[2006];int p[2006], q[2006];

2013-08-29 10:36:46 901

原创 POJ 2942 Knights of the Round Table 边双连通分量求解

边双连通分量求解要点:1.通过割点找变双连通分量。2.点入栈,当前边(u->v)的v点等于栈顶的点时停止出栈。3.每个割点可能属于多个连通分量。 G++ AC,哪位大神帮忙改成C++ ACView Code #include#includestring.h>#include#includeusing namespace std;#define max

2013-08-29 10:36:43 669

原创 ZOJ 2588 Burning Bridges 求割边

注意:去掉反向边View Code #include#includestring.h>#includeusing namespace std;#define maxn 10004#define maxm 100055#define inf 1000000000int min(int a, int b){ return a a : b;

2013-08-29 10:36:41 819

原创 POJ 1144 Network 求割点个数

View Code #include#includestring.h>#define maxn 110#define maxm maxn * maxn#define inf 1000000000int min(int a, int b){ return a a : b;}struct E{ int v, next;}ed

2013-08-29 10:36:39 908

原创 HDU 1060 Leftmost Digit 数学题

http://www.cppblog.com/LeoW/archive/2012/03/08/167427.htmlView Code #include#includestring.h>#include#define lld __int64int main(){ int i, j, cas; int n; scanf("%d", &ca

2013-08-29 10:36:37 837

原创 HDU 1717 小数化分数2

http://www.cnblogs.com/183zyz/archive/2011/04/12/2013372.htmlView Code #include#includestring.h>int f(int x){ int i, sum = 1; for(i = 1; i ) sum *= 10; return sum;

2013-08-29 10:36:34 837

原创 HDU 4431 Mahjong 2012天津A题 模拟题

思路:枚举每张牌,然后加入这张牌,看这牌是否能胡。判胡:1.注意特判 7 对子,九一 这两个胡牌规则         2.(胡的牌里必须有一个对子)枚举这个对子,然后再进行处理就方便多了注意:情况1特判和情况2的牌可能会重复,要去重。View Code #include#includestring.h>#includeusing namespace std;

2013-08-29 10:36:32 844

原创 POJ 1966 Cable TV Network 顶点连通度的求解

用拆点把点权变为边权。然后用最大流求解每对u、v(u != v),取其中的最小值注意:具体操作时,有个技巧,可以将枚举从O(n^2)优化到O(n):先固定一个点,然后枚举另一个点即可。很显然的一个结论:max_flow(1->2->3) 3)我们要取其中的最小,可以不必去求2->3的最大流如果以1为源点,汇点只能是剩下的几个点,枚举汇点即可。 本题要多次求最大流,所

2013-08-29 10:36:30 831

原创 重连通分量的求解

提两点:1.对于每个点连通分量,都是根据割点来找的。2.边入栈, 到当前边等于栈顶时停止出栈。3.割点属于多个点连通分量。邻接矩阵:View Code #include#includestring.h>#define maxn 22#define maxm 444#define inf 1000000000int min(int a, int b

2013-08-29 10:36:27 952

原创 POJ 1523 SPF tarjan算法入门

注意:对于生成树的每条边:u是割点的充要条件是:1、若u为根节点, 它有2个以上包括两个的儿子(son >= 2)2、u不为根节点,dfn[u] View Code #include#includestring.h>#define maxn 1005#define maxm maxn*maxnint min(int a, int b) { retur

2013-08-29 10:36:25 770

原创 POJ 2516 Minimum Cost k次费用流

View Code #include#includestring.h>#include#includeusing namespace std;#define maxn 110#define maxm 6000#define inf 1000000000int min(int a, int b){ return a a : b;}s

2013-08-29 10:36:21 697

原创 poj2195 Going Home 费用流

View Code #include#includestring.h>#include#includeusing namespace std;#define maxn 100300#define maxm 200003#define inf 1000000000int min(int a, int b){ return a a : b;

2013-08-29 10:36:18 720

原创 POJ 3422 Kaka&#39;s Matrix Travels 费用流

View Code #include#includestring.h>#include#includeusing namespace std;#define maxn 5010#define maxm 10030#define inf 1000000000int min(int a, int b){ return a a : b;}

2013-08-29 10:36:16 793

原创 POJ 2135 Farm Tour 费用流入门题

View Code #include#includestring.h>#include#includeusing namespace std;#define maxn 1010#define maxm 10003#define inf 1000000000int min(int a, int b){ return a a : b;}

2013-08-29 10:36:14 845

原创 POJ 2396 Budget 上下界网络流 经典题

View Code #include#includestring.h>#define maxn 504#define maxm 100003#define inf 1000000000int min(int a, int b){ return a a : b;}int max(int a, int b){ return a >

2013-08-29 10:36:12 934

操作系统实验

4个实验的ppt,有详细的代码,适合初学者

2013-10-23

UVALive 2218

半平面交入门题

2013-09-27

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除