Shirlies
宁静专注认真的程序媛~
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 21 下一页
摘要: 不错的一道题目,但是中途我还是出问题了,代码中有注释代码如下: 1 #include <cstdio> 2 #include <cstring> 3 4 struct node 5 { 6 int x,y; 7 }ans[1005]; 8 9 int g[200][200];10 bool vis[200];11 int link[200];12 int match[200];13 int n;14 15 void init()16 {17 memset(link, -1,sizeof(link));18 }19 20 bool can(int x)21 {22 f.. 阅读全文
posted @ 2012-05-11 15:47 Shirlies 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 有时候都不太想写博客了,(~ o ~)~zZ这一题是纯粹的二分图匹配,不过要注意一点哈“At the beginning they are both work at mode_0”,所以要判断一下两点连接的时候是不是存在0这个点if(a && b)pro[a].push_back(b);代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <vector> 4 using namespace std; 5 6 int vis[200]; 7 int link[200]; 8 vec 阅读全文
posted @ 2012-05-10 13:19 Shirlies 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 第一道网络流的题目,我是看这个讲解的http://www.nocow.cn/index.php/%E7%BD%91%E7%BB%9C%E6%B5%81Edmonds-Karp 算法主要是顶点有值限制,所以可以将一个点分成两个点a和a',它们两个之间的容量就是顶点的值代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 using namespace std; 5 6 const int maxn = 300; 7 const int inf = 0x7fffffff; 阅读全文
posted @ 2012-05-10 00:14 Shirlies 阅读(275) 评论(0) 推荐(0) 编辑
摘要: 表示很无语的一题,纯粹意义上的字符处理,晕...用优先队列做的,时间0ms...代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 using namespace std; 5 6 struct node 7 { 8 int u,v; 9 int w; 10 }p[5000]; 11 int d[1000]; 12 int n,m; 13 int num; 14 int first[5000]; 15 int nextt[5000]; 16 typedef pair<i 阅读全文
posted @ 2012-05-04 21:13 Shirlies 阅读(338) 评论(0) 推荐(0) 编辑
摘要: 心血来潮,用优先队列实现了这个Dijkstra,顺便练练静态链表,不过结果也蛮不错的,在acm steps里面是93msA的,在外面却是109ms,排名很靠前,好开心,不过也郁闷,竟然有人31ms过了,汗...到底是怎么样的一个牛人啊......代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 using namespace std; 5 6 const int maxn = 20000 + 100; 7 int n,m,endd; 8 typedef pair<in 阅读全文
posted @ 2012-05-02 20:44 Shirlies 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 在此郑重的向南柯小朋友表示我的感谢!!如果不是他告诉我输入的时候需要处理if(g[a][b] == -1 || g[a][b] > w)g[a][b] = g[b][a] = w;(从一个点到另外一个点竟然有好几种选择,囧,我们仅仅需要考虑最小的就ok了)这个东西的话,相信我是找不出问题来的.......也向他表示感谢HDU today这一题也是他找出了问题,就是起点和目的地相同的情况我没有考虑......代码如下: 1 #include <cstdio> 2 #include <cstring> 3 4 int g[200][200]; 5 int vis[20 阅读全文
posted @ 2012-05-02 18:29 Shirlies 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 吐吐槽吧:本来思路完全对了,但是那个二分查找搞错了,我还以为一个就可以了,结果查找上界和下界分别要一个查找函数(WA时就看了一下别人的代码,发现别人都是用两个查找函数的,模仿别人写的查找函数),自己得好好揣摩揣摩。。。还有就是最后的结果可能是负数。。。因为get_sum的值是小于9901的,而N的值可大于9901代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 5 const int mod = 9901; 6 const int maxn = 100000 + 1 阅读全文
posted @ 2012-04-30 16:55 Shirlies 阅读(305) 评论(0) 推荐(0) 编辑
摘要: 这一题是访别人写的,第一道差分约束的题目,但是现在做一题就得整理模板了。。。至少把它的思想好好记住http://blog.sina.com.cn/s/blog_60707c0f0100xht7.html这个讲差分约束的,算法导论上面也有,还是比较喜欢看纸质版的。代码来自http://www.cnblogs.com/staginner/archive/2011/10/20/2218421.html 阅读全文
posted @ 2012-04-20 15:31 Shirlies 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 最短路Dijkstra算法,用优先队列。。。代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 #include <vector> 5 using namespace std; 6 7 const int maxn = 50010; 8 struct node 9 {10 int v;11 int w;12 };13 14 typedef pair<int,int> pii;15 vector<node> p[2*maxn];16 int 阅读全文
posted @ 2012-04-18 17:14 Shirlies 阅读(356) 评论(0) 推荐(0) 编辑
摘要: 表示对这类题目没feel,抽象。。。参考别人的代码后写出来的,顺便练习了一下FIFO队列实现Bellman-ford算法。。。代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 #include <cmath> 5 using namespace std; 6 7 int g[6][105]; 8 int n,k; 9 int t[6];10 int d[105];11 int v[105];12 13 void init()14 {15 for(int i = 阅读全文
posted @ 2012-04-17 21:09 Shirlies 阅读(259) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 21 下一页