2011年7月29日

摘要: #include <iostream> #include<cstdio> #include <queue> #include<string.h> using namespace std; const int MAX=99999; int mat[105][105]; int N,lowcost[105],road; void prime() { for(int i=2;i<=N;i++) lowcost[i]=mat[1][i]; for(int i=2;i<=N;i++) { int temp=lowcost[i],k=i; for 阅读全文
posted @ 2011-07-29 19:32 ljfbest 阅读(87) 评论(0) 推荐(0)
摘要: 这次写并查集比上一题有太多的优化了,oh yeah! 注意其中的压缩优化……#include <iostream> #include<cstdio> #include <queue> #include<string.h> using namespace std; int pre[30005]; int num[30005]; void makeSet(int n) { for(int i=0;i<n;i++) { num[i]=1; pre[i]=i; } } int findSet(int m) { if(pre[m]!=m) pre[m 阅读全文
posted @ 2011-07-29 17:01 ljfbest 阅读(65) 评论(0) 推荐(0)
摘要: 终于有时间搞算法了,估计时间又不长,(~ o ~)~zZ,决定以后不管学习任务多重都要坚持ac,(=@__@=)努力!!!#include <iostream> #include<cstdio> #include <queue> #include<string.h> using namespace std; int pre[105]; int ufs(int p) { int t1=p,t2; while(p!=pre[p]) p=pre[p]; while(t1!=p) { t2=pre[t1]; pre[t1]=p; t1=t2; } ret 阅读全文
posted @ 2011-07-29 10:34 ljfbest 阅读(70) 评论(0) 推荐(0)
摘要: 并查集是我暑假从高手那里学到的一招,觉得真是太精妙的设计了。以前我无法解决的一类问题竟然可以用如此简单高效的方法搞定。不分享出来真是对不起party了。(party:我靠,关我嘛事啊?我跟你很熟么?)来看一个实例,杭电1232畅通工程 http://acm.hdu.edu.cn/showproblem.php?pid=1232首先在地图上给你若干个城镇,这些城镇都可以看作点,然后告诉你哪些对城镇之间是有道路直接相连的。最后要解决的是整幅图的连通性问题。比如随意给你两个点,让你判断它们是否连通,或者问你整幅图一共有几个连通分支,也就是被分成了几个互相独立的块。像畅通工程这题,问还需要修几条路,实 阅读全文
posted @ 2011-07-29 09:07 ljfbest 阅读(128) 评论(0) 推荐(0)
摘要: 这个是php100上面的,关于图片上传方面几乎每个细节都考虑到了,直接复制代码就可以用了,很牛很强大,(~ o ~)~zZ<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php /****************************************************************************** 参数说明: $max_file_size : 上传文件大小限制, 单位BYTE $destination_f 阅读全文
posted @ 2011-07-29 08:54 ljfbest 阅读(112) 评论(0) 推荐(0)

导航