木其网络科技专业程序员代写http://www.xmsydw.com
程序员学历擅长经验网店链接
apenny硕士ASP.NET PHP 电子 通信设计 图像 编程 网络5年进入店铺
zheng_qianqian本科C语言 C++面向对象 Java3年进入店铺
guoguanl本科Java Web项目 JSP Hibernate Struts Mysql4年进入店铺

随笔分类 -  图论

摘要:大致题意:就是给出三维坐标系上的一些球的球心坐标和其半径,搭建通路,使得他们能够相互连通。如果两个球有重叠的部分则算为已连通,无需再搭桥。求搭建通路的最小费用(费用就是边权,就是两个球面之间的距离)。#include #include using namespace std; int vis[105],n; double map[105][105],l; double dis(double x1,double y1,double z1,double x2,double y2,double z2) { return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z. 阅读全文
posted @ 2013-06-13 08:56 C语言程序 阅读(141) 评论(0) 推荐(0) 编辑
摘要:#include int fa[10001],di[10001],n,m; int find(int v) { if(fa[v]!=1 && fa[v]!=v) fa[v]=find(fa[v]); return fa[v]; } int find1(int v) { if(di[v]!=1 && di[v]!=v) di[v]=find1(di[v]); return di[v]; } void Unio(int x,int y) { if(x>1) fa[x]=find(y); if(y>1) di[y]=fi... 阅读全文
posted @ 2013-06-12 00:27 C语言程序 阅读(173) 评论(0) 推荐(0) 编辑
摘要:// Time 1062 ms, Memory 4252K#include #include int map[1010][1010],vis[1010],a[1010],b[1010],k; int f1(int u) { int v; for(v=0;v<k;v++) { if(map[u][v] && !vis[v]) { vis[v]=1; if(!b[v] || f1(b[v])) { a[u]=v;b[v]=u;return ... 阅读全文
posted @ 2013-06-11 16:32 C语言程序 阅读(194) 评论(0) 推荐(0) 编辑
摘要:#include #include int map[105][105],vis[105][105],ans,n,father[105]; int find(int x) { while(x!=father[x]) x=father[x]; return x; } int main() { int i,j,k,a,b,d,t,min1,min2,state,tt,num; while(scanf("%d",&n)==1 && n) { memset(vis,0,sizeof(vis)); memset(map... 阅读全文
posted @ 2013-06-08 13:45 C语言程序 阅读(145) 评论(0) 推荐(0) 编辑
摘要:这题是我在没学Dijkstra算法时做的,所以跟模板有点不一样,但是意思差不多。如果要看标准的Dijkstra算法的话,可以去查有关知识。代码如下:// Time 0ms, Memory 5884K#include #include int map[1200][1200],v1[1200],v2[1200],l,d1[1200],d; int f(int x) { int i,min,n=0,y,z,m=-1,v[1200]; memset(d1,-1,sizeof(d1)); memset(v,-1,sizeof(v)); y=x;d1[x]=0; w... 阅读全文
posted @ 2013-06-07 20:39 C语言程序 阅读(320) 评论(0) 推荐(0) 编辑
摘要:#include #include int map[510][510],vis[510],a[510],b[510],n,m,k; int f1(int u) { int v; for(v=1;v<=n;v++) { if(map[u][v] && !vis[v]) { vis[v]=1; if(!b[v] || f1(b[v])) { a[u]=v;b[v]=u;return 1; } } ... 阅读全文
posted @ 2013-06-07 14:06 C语言程序 阅读(256) 评论(0) 推荐(0) 编辑
摘要:转自http://blog.csdn.net/allenjy123/article/details/6627248红色已经AC一、最短路POJ 2449 Remmarguts' Date(中等)http://acm.pku.edu.cn/JudgeOnline/problem?id=2449题意:经典问题:K短路解法:dijkstra+A*(rec),方法很多相关:http://acm.pku.edu.cn/JudgeOnline/showcontest?contest_id=1144该题亦放在搜索推荐题中POJ 3013 - Big Christmas Tree(基础)http:// 阅读全文
posted @ 2013-06-06 13:05 C语言程序 阅读(247) 评论(0) 推荐(0) 编辑
摘要:题意大概是这样的:用一个7位的string代表一个编号,两个编号之间的distance代表这两个编号之间不同字母的个数。一个编号只能由另一个编号“衍生”出来,代价是这两个编号之间相应的distance,现在要找出一个“衍生”方案,使得总代价最小,也就是distance之和最小。#include #include using namespace std; int map[2010][2010],vis[2010],n,sum; void f(int t) { int i,j=n-2,min=0; while(j--) { for(i=1;imap[t][i]) map[0][i]=ma... 阅读全文
posted @ 2013-05-19 16:59 C语言程序 阅读(88) 评论(0) 推荐(0) 编辑
摘要://Time 47ms, Memory 308K#include #include #include using namespace std; const int inf=0xfffffff; queueq; int cap[55][55],flow[55][55],d[2505],e[2505],n,p,cnt=0,vis[55][55]; void f1(int i) { int j; for(j=1;j0 && !vis[i][j]) { vis[i][j]=1; if(i) { cnt++;... 阅读全文
posted @ 2013-05-19 09:03 C语言程序 阅读(124) 评论(0) 推荐(0) 编辑
摘要://Time 63ms, Memory 572K#include #include #include using namespace std; class coordinate { public: double x,y; }point[201]; double path[201][201]; //两点间的权值 int main(void) { int i,j,k; int cases=1; while(cases) { /*Read in*/ ... 阅读全文
posted @ 2013-05-19 08:58 C语言程序 阅读(116) 评论(0) 推荐(0) 编辑
摘要://Time 250ms, Memory 332K#include #include using namespace std; int cnt,n,m1,m2; struct point { int a,b; double t; point(int a=0,int b=0,double t=0.0):a(a),b(b),t(t){} }p[6000]; int bellman() { int i,j; int flag; double dis[505]; for(i=0;idis[p[j].a]+p[j].t) {... 阅读全文
posted @ 2013-05-19 08:55 C语言程序 阅读(140) 评论(0) 推荐(0) 编辑
摘要://Time 16ms, Memory 244K#include #include using namespace std; int cnt,n,m,s; double v; struct point { int a,b; double r,c; point(int a=0,int b=0,double r=0.0,double c=0.0):a(a),b(b),r(r),c(c){} }p[201]; int bellman() { int i,j; int flag; double dis[101]; memset(dis,0,siz... 阅读全文
posted @ 2013-05-19 08:49 C语言程序 阅读(172) 评论(0) 推荐(0) 编辑
摘要:最大流-多源多汇问题建立超级源点,超级汇点#include #include #include #include using namespace std; const int inf=0xfffffff; queueq; int n,np,nc,m,s,t; int cap[105][105],flow[105][105],d[105],g[105][105]; int main() { int i,a,b,c,f,ss; char s1,s2,s3; while(cin>>n>>np>>nc>>m) { s=n;t=n+1; m... 阅读全文
posted @ 2013-05-18 19:48 C语言程序 阅读(176) 评论(0) 推荐(0) 编辑
摘要:最短路问题#include #include using namespace std; const int inf=0xfffffff; int dis[101],vis[101],map[101][101],v[101]; int n,m; int dijkstra() { int i,j,sd,node; for(i=1;idis[j]) { sd=dis[j];node=j; } } if(node==0) break; vis[node]=1;... 阅读全文
posted @ 2013-05-18 19:25 C语言程序 阅读(120) 评论(0) 推荐(0) 编辑
摘要:这题也可以用搜索来做但用匹配做更简单//Time 0ms,Memory 332K#include #include using namespace std; char city[4][5]; int n,l1,l2,vis[10],flag[10],p[4][4],q[4][4],pq[10][10]; int f(int u) { int i; for(i=0;i>n && n) { l1=0;t=0; memset(p,0,sizeof(p)); memset(q,0,sizeof(q)); memse... 阅读全文
posted @ 2013-05-18 15:49 C语言程序 阅读(186) 评论(0) 推荐(0) 编辑

木其网络科技专业程序员代写http://www.xmsydw.com
程序员学历擅长经验网店链接
apenny硕士ASP.NET PHP 电子 通信设计 图像 编程 网络5年进入店铺
zheng_qianqian本科C语言 C++面向对象 Java3年进入店铺
guoguanl本科Java Web项目 JSP Hibernate Struts Mysql4年进入店铺
点击右上角即可分享
微信分享提示