2012年7月31日

poj 2151 Check the difficulty of problems (DP)

摘要: 点击打开链接 在acm比赛中,n题,t队。给出每个队做对每题的概率,问每队至少对一题,至少有一队做对至少m题的概率 dp,f[i][j]表示第i个队伍做对第j题的概率。g[i][j][k]表示第i个队伍对于前j题而言做对k道的概率。 g[i][j][k] = g[i][j - 1][k - 1... 阅读全文

posted @ 2012-07-31 20:33 Slege 阅读(147) 评论(0) 推荐(0) 编辑

poj 1860 Currency Exchange (Bellman_Ford)

摘要: 点击打开链接 第一次写Bellman_Ford.. #include"stdio.h"int n,m,start;double money,rab,rba,cba,cab;struct node{ int x,y; double r,c;}map[210];double d[210];int... 阅读全文

posted @ 2012-07-31 19:40 Slege 阅读(93) 评论(0) 推荐(0) 编辑

hdu 1548 A strange lift (bfs)

摘要: 点击打开链接 简单BFS。。 #include"stdio.h"#include"string.h"#include"queue"using namespace std;struct node{ int x,step;}q,p;int main(){ int d[201],mark[202]... 阅读全文

posted @ 2012-07-31 18:42 Slege 阅读(83) 评论(0) 推荐(0) 编辑

POJ 3626 Mud Puddles (BFS)

摘要: 点击打开链接 将所有的数据都+500,然后模版。。 #include"stdio.h"#include"string.h"#include"queue"using namespace std;int d[4][2]={1,0,0,1,-1,0,0,-1};int x,y,n,map[1001... 阅读全文

posted @ 2012-07-31 18:39 Slege 阅读(117) 评论(0) 推荐(0) 编辑

hdu 3367 Pseudoforest (krusual)

摘要: 点击打开链接 求一个最大的生成森林,每个连通的部分最多有一个环,求其权值最大的森林。。。。 比如说各个点都有各自的一个集合,那么对于新读入的2点,若他们这个集合里面已经有环,就不能在忘这里面添加边了,再添加边必定会构成新的环,若他们属于两个不同的集合,若他们两个集合都有环了,不能在把他们连起... 阅读全文

posted @ 2012-07-31 17:18 Slege 阅读(126) 评论(0) 推荐(0) 编辑

poj 1679 The Unique MST (最小生成树)

摘要: 点击打开链接 判断最小生成树是否唯一! 用prime算法,其中然后加一步:假设枚举到M点如果 ((已经加入生成树中的点到M的权值等于未加入点M的权值)的个数)大于1,则肯定不是唯一! #include"stdio.h"#include"string.h"#define INF 9999999... 阅读全文

posted @ 2012-07-31 15:38 Slege 阅读(105) 评论(0) 推荐(0) 编辑

poj 2253 Frogger (最短路Floyd)

摘要: 点击打开链接 wrong了2次,因为没读懂题!! 唉, 英语好差啊!! 题目大意: 给出两只青蛙的坐标A、B,和其他的n-2个坐标,任一两个坐标点间都是双向连通的。显然从A到B存在至少一条的通路,每一条通路的元素都是这条通路中前后两个点的距离,这些距离中又有一个最大距离。题目要求,必须借助第... 阅读全文

posted @ 2012-07-31 14:41 Slege 阅读(94) 评论(0) 推荐(0) 编辑

poj 2377 Bad Cowtractors (最‘大’生成树)

摘要: 点击打开链接 最小生成树的变形,最大生成树 #include"stdio.h"#include"math.h"#include"string.h"#define INF 0int map[1001][1001],f[1001];int mark[1001],n;void prime(){ i... 阅读全文

posted @ 2012-07-31 11:23 Slege 阅读(142) 评论(0) 推荐(0) 编辑

poj 3625 Building Roads (最小生成树)

摘要: 点击打开链接 坐标类型的最小生成树 注意,所有的距离用double,所有的int用__int64 #include"stdio.h"#include"math.h"#include"string.h"#define INF 100000000double map[1001][1001],f[... 阅读全文

posted @ 2012-07-31 11:10 Slege 阅读(106) 评论(0) 推荐(0) 编辑

poj 1005 I Think I Need a Houseboat

摘要: 点击打开链接 大体意思:半圆表示一块面积可扩展的区域,开始时,面积是0,在(0,0)处开始以每年50平方米的速度同样呈半圆扩展,输入一个正整数N,然后输入N对坐标,对于每一对坐标值:求出面积扩展到该点的年数,坐标值单位为米。 #include"stdio.h"#include"math.h"... 阅读全文

posted @ 2012-07-31 09:43 Slege 阅读(141) 评论(0) 推荐(0) 编辑

zoj 1586 QS Network (最小生成树)

摘要: 点击打开链接 注意每个点也有价值。 #include"stdio.h"#include"string.h"#define INF 1000000000int mark[1001],f[1001],n,map[1001][1001];void prime(){ int i,j,min,k,an... 阅读全文

posted @ 2012-07-31 09:06 Slege 阅读(116) 评论(0) 推荐(0) 编辑

poj1789 Truck History (最小生成树)

摘要: 点击打开链接 历史上,曾用7个小写字母来表示每种truck的型号,每两种型号之间的差距为字母串中不同字母的个数。现在给出n种不同型号的truck,问怎样使 1/Σ(to,td)d(to,td)的值最小。(即找到一条连接所有truck的最短路径。典型的最小生成树的问题, discuss里说,Pr... 阅读全文

posted @ 2012-07-31 08:51 Slege 阅读(144) 评论(0) 推荐(0) 编辑

一位ACMer过来人的心得

摘要: 刻苦的训练我打算最后稍微提一下。主要说后者:什么是有效地训练? 我想说下我的理解。 很多ACMer入门的时候,都被告知:要多做题,做个500多道就变牛了。其实,这既不是充分条件、也不会是必要条件。 我觉得一般情况下,对于我们普通学校的大学生,各方面能力... 阅读全文

posted @ 2012-07-31 08:23 Slege 阅读(91) 评论(0) 推荐(0) 编辑

poj 2677 Tour (最短路)

摘要: 点击打开链接 #include"stdio.h"#include"math.h"#define INF 9999999struct point{ double x,y;}point[202];int n;double dis[202][202],b[202][202];double dista... 阅读全文

posted @ 2012-07-31 07:59 Slege 阅读(92) 评论(0) 推荐(0) 编辑

poj 1251Jungle Roads (最小生成树:prime+krusual)

摘要: 点击打开链接 krusual: #include"stdio.h"#include"stdlib.h"int set[101];struct node{ int a,b,dis;}aa[101];int find(int x){ int r,i; r=x; while(set[r]!=r) ... 阅读全文

posted @ 2012-07-31 07:59 Slege 阅读(87) 评论(0) 推荐(0) 编辑

poj1258 Agri-Net (最小生成树prime)

摘要: prime,模版 点击打开链接 #include"stdio.h"#include"string.h"#define INF 9999999int map[101][101],f[101],mark[101],n;void prime(){ int i,j,k,min,ans; memset... 阅读全文

posted @ 2012-07-31 07:59 Slege 阅读(101) 评论(0) 推荐(0) 编辑

poj 2485Highways (求最长路)

摘要: 点击打开链接 最小生成树的变化。。 求最长的路的值。。 #include"stdio.h"#include"string.h"#define INF 9999999int map[501][501],f[501],mark[501],n;void prime(){ int i,j,k,min... 阅读全文

posted @ 2012-07-31 07:59 Slege 阅读(114) 评论(0) 推荐(0) 编辑

poj 1308 Is It A Tree? (最小生成树)

摘要: 点击打开链接 最小生成树。。 #include"stdio.h"int set[1002],v[1003],cnt[1002],flag;void fun(){ int i; flag=0; for(i=1;i1) t++; } if(t>1) return -... 阅读全文

posted @ 2012-07-31 07:59 Slege 阅读(86) 评论(0) 推荐(0) 编辑

poj 1703 Find them, Catch them (并查集)

摘要: 点击打开链接 #include"stdio.h"int f[100005];int r[100005];void set(int n){ int i; for(i=1;i<=n;i++) { f[i]=i;r[i]=0; }}int find(int x){ int t; if(x!=f[x... 阅读全文

posted @ 2012-07-31 07:59 Slege 阅读(76) 评论(0) 推荐(0) 编辑

poj 1456 Supermarket (最短路程)

摘要: 点击打开链接 #include"stdio.h"#include"stdlib.h"struct node{ int p,t;}aa[10005];int f[10005],n;int cmp(const void*a,const void*b){ return (*(struct node*... 阅读全文

posted @ 2012-07-31 07:59 Slege 阅读(69) 评论(0) 推荐(0) 编辑

导航