03 2012 档案

Alice's Chance poj 1698
摘要:刚开始我是则这样构图的1.源点到1-7天的天数为最大的周数2.每天与其对应的演电影的时间连接,容量为其周数3.把每部电源的所有演出时间点再汇聚到一个节点(容量为inf),再把这个节点与汇点连边,容量为该部电源其所需天数。这样构图,一直wa, 早上起来才想到,没有考虑时间先后顺序。如这组测试数据331 1 1 1 1 1 1 105 151 1 1 1 1 1 1 14 21 1 1 1 1 1 1 7 20正确的构图应该这样, 把所有时间(那天可以演电影的对应一个点,最后得到一个时间的点集。20 1 0 1 0 1 0 9 31.构造时间的点集合为point = { day{ (week - 阅读全文

posted @ 2012-03-24 09:24 more think, more gains 阅读(175) 评论(0) 推荐(0)

hdu 3081 Marriage Match II
摘要:Sample Input14 5 21 1233 24 2441 42 3结合输入数据讲题意,1,就是一组输入数据,4表示有2 * 4个人,女生编号为1-4, 男生编号也为1-4,5表示下面接下来5对关系是没有吵过架的,2表示为有2对女生女生是好朋友的关系,也就是最后输入的那两行题目是要我们求每个女生找一个男生,并且这个男生没有和她吵过架,如果她朋友没有跟这个男生吵过架也可以。还有就是女生之间的朋友关系可以传递。但是不能找以前她已经找过的男生。。当每个女生找到一个男生后,这个游戏就算玩了一次,然后接着继续玩。要我们解决的问题是,这个游戏最多可以玩几圈。算法:1.并查集因为女生之间的朋友关系可以 阅读全文

posted @ 2012-03-19 22:54 more think, more gains 阅读(300) 评论(0) 推荐(0)

public 继承
摘要:View Code #include <iostream>#include <string>#include <cstdlib>using namespace std;class student{ public: student( ) { name = "tang"; num = "104080219"; sex = "M"; } void display( ); void input( ); private: string name; string num; string sex;};class 阅读全文

posted @ 2012-03-19 15:25 more think, more gains 阅读(176) 评论(0) 推荐(0)

c++ 运算符重载
摘要:View Code /*运算符重载,类型转换函数,转换构造函数无参默认构造函数,带参初始化构造函数,*/#include <iostream.h>//#include <iostream>#include <cstdlib>//using namespace std;class Complex{ public: Complex( ) { real = 0; imag = 0; } //无参默认构造函数 //Complex(double r) { real = r; imag = 0;} 转换构造函数 Complex(double r, double i) { 阅读全文

posted @ 2012-03-19 14:41 more think, more gains 阅读(132) 评论(0) 推荐(0)

最短路复习
摘要:HDU 1874 1.dijkstra 算法View Code #include<stdio.h>#include<string.h>#include<stdlib.h>#include<algorithm>using namespace std;const int inf = 0x7f7f7f7f;int mp[400][400];int visit[400];int dis[400];int S, T;void dij( int N ){ for( int i = 0; i < N; i++) { visit[i] = 0; dis[i 阅读全文

posted @ 2012-03-13 14:11 more think, more gains 阅读(150) 评论(0) 推荐(0)

并查集最小生成树复习
摘要:HDU 1856 more is better 简单并查集View Code #include <stdio.h>int set[100010], num[100010];int maxn = 1;int find( int x){ // return x == set[x] ? x : set[x] = find(set[x]); if( x != set[x] ) { set[x] = find(set[x]); } return set[x];}void merge( int x, int y){ int x1 = find( x ); int y1 = find( ... 阅读全文

posted @ 2012-03-11 11:17 more think, more gains 阅读(185) 评论(0) 推荐(0)

网络流算法之一
摘要:1. Edmonds-karp 算法用广度优先搜索来实现对增广路径p的计算,即如果增广入径是残留网络中从(s到t的最短路径,就能改进FORD-FULKERSON的界,称Ford-Fulkerson方法的这种实现为Edmonds-karp算法,时间复杂度为O(VE^2);HDU 3549View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <deque>using namespace std;int cap[100][100];int a[100];in 阅读全文

posted @ 2012-03-08 23:24 more think, more gains 阅读(576) 评论(0) 推荐(0)

二分图KM算法 HDU 2255
摘要:在百度百科学了KM算法。。km算法是求完备匹配下的最大权KM算法流程:1.对二分图的两部分顶点初始化2.KM算法用匈牙利算法寻找完备匹配3.如果未找到就修改相应顶点值4重复(2)(3)直到找到相等子图的完备匹配为止;HDU 2255是裸题。。未优化版:View Code #include<stdio.h>#include<string.h>#include<stdlib.h>int match[1000];int mp[400][400];bool visitx[400], visity[400];int xx[400], yy[400];const int 阅读全文

posted @ 2012-03-08 14:11 more think, more gains 阅读(294) 评论(0) 推荐(0)

简单二分图匹配
摘要:1.HDU 2063 过山车模板题。。View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <algorithm>#include <queue>#include <deque>#include <list>#include <map>#include <set>#include <stdlib.h>#include <time.h>using namespace st 阅读全文

posted @ 2012-03-07 22:14 more think, more gains 阅读(193) 评论(0) 推荐(0)

母函数
摘要:晚上写了几道简单的母函数。母函数万变不离其宗。。1.HDU1171View Code #include <stdio.h>#include <string.h>#include <stdlib.h>int value[2000], num[2000];int c1[250010], c2[250010];int sum = 0;void fun(int N){ int cnt = num[1]; memset(c1, 0, sizeof(c1)); memset(c2, 0, sizeof(c2)); for( int i = 0; cnt >= 0; 阅读全文

posted @ 2012-03-06 22:53 more think, more gains 阅读(268) 评论(0) 推荐(0)

poj 3468 A Simple Problem with Integers
摘要:1.线段树 2700ms..View Code /*Source CodeProblem: 3468 User: 314911229Memory: 12928K Time: 2704MSLanguage: G++ Result: AcceptedSource Code*/#include <stdio.h>#include <string.h>#include <stdlib.h>struct node{int l, r;long long lazy, sum;}T[500000];long long ans[101000];long long sum... 阅读全文

posted @ 2012-03-06 13:24 more think, more gains 阅读(219) 评论(0) 推荐(0)

I HATE IT 伸展树
摘要:View Code #include <stdio.h>#include <string.h>#include <algorithm>#include <stdlib.h>#include <math.h>#include <algorithm>#include <time.h>using namespace std;int left[200100], right[200100], maxn[200100], pf[200100], value[200100],root; //值为-1的点表示该结点为空 voi 阅读全文

posted @ 2012-03-05 00:54 more think, more gains 阅读(191) 评论(0) 推荐(0)

SPLAY树各种操作--链表
摘要:SPLAY树各种操作1.旋转2.插入3.删除4.查找5前驱6.后继7第k小/大8根据秩求元素View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <algorithm>using namespace std;//节点定义typedef struct node{ node *child[2], *pf; int v, size;}*Node;Node root = NULL;void preordertravel( Node p ){ if( p ) { 阅读全文

posted @ 2012-03-05 00:40 more think, more gains 阅读(350) 评论(0) 推荐(0)

1208: [HNOI2004]宠物收养所
摘要:1208: [HNOI2004]宠物收养所1.用Treap树写:只需要三个操作,插入,删除,查找(同时找出其前继后继);View Code /************************************************************** Problem: 1208 User: 314911229 Language: C++ Result: Accepted Time:268 ms Memory:1732 kb*************************************************************... 阅读全文

posted @ 2012-03-04 20:31 more think, more gains 阅读(582) 评论(1) 推荐(0)

STL 平衡树数据结构容器
摘要:1.mapkey只能对应一个映射值,支持插入,删除,查找(count, find), 修改(先删除此值,再插入修改后的值),排序,映射(离散话) multimap同样的键值可有多个映射View Code #include <stdio.h>#include <stdlib.h>#include <algorithm>#include <map>using namespace std;map<int, int>mp; int main( ){ int N,M, t; char str[1000]; while( scanf(" 阅读全文

posted @ 2012-03-04 14:40 more think, more gains 阅读(347) 评论(0) 推荐(0)

1503: [NOI2004]郁闷的出纳员
摘要:1503: [NOI2004]郁闷的出纳员Time Limit:5 SecMemory Limit:64 MBSubmit:2056Solved:711[Submit][Status][Discuss]DescriptionOIER公司是一家大型专业化软件公司,有着数以万计的员工。作为一名出纳员,我的任务之一便是统计每位员工的工资。这本来是一份不错的工作,但是令人郁闷的是,我们的老板反复无常,经常调整员工的工资。如果他心情好,就可能把每位员工的工资加上一个相同的量。反之,如果心情不好,就可能把他们的工资扣除一个相同的量。我真不知道除了调工资他还做什么其它事情。 工资的频繁调整很让员工反感,尤其 阅读全文

posted @ 2012-03-04 00:28 more think, more gains 阅读(246) 评论(0) 推荐(0)

Splay树各操作--数组
摘要:伸展树删除元素非常方便。。View Code #include <stdio.h>#include <string.h>#include <algorithm>#include <stdlib.h>#include <math.h>#include <algorithm>#include <time.h> using namespace std; int left[100010], right[100010], pf[100010];int value[100010];int num[100010]; //记录 阅读全文

posted @ 2012-03-03 22:44 more think, more gains 阅读(227) 评论(0) 推荐(0)

Treap树各种操作
摘要:今天写了Treap树的各种操作。。1.插入元素2.删除元素3.查找元素4.求第K小元素5确定一个元素秩6求最大值7求最小值8遍历View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <time.h>typedef struct node{ node *lchild, *rchild, *pf;//左孩子,右孩子 int v, pri, size;//值和优先值}*Node;void update( Node &q ){ if( q->rc 阅读全文

posted @ 2012-03-03 21:53 more think, more gains 阅读(269) 评论(0) 推荐(0)

导航