Constructing Roads(SPFA+邻接表)
摘要:题目描述 Long long ago, There was a country named X, the country has N citieswhich are numbered from 1 to N. The king of Country-X wants to construct some roads. Please note that Country-X is blessed by an angel. He(The angel is a boy? This is no science, but do not care about those details, this ange..
阅读全文
posted @
2013-11-22 18:55
straw_berry
阅读(206)
推荐(0)
Invitation Cards(邻接表+逆向建图+SPFA)
摘要:Time Limit:8000MSMemory Limit:262144KTotal Submissions:17538Accepted:5721DescriptionIn the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. They have printed inv
阅读全文
posted @
2013-11-12 21:56
straw_berry
阅读(410)
推荐(0)
zoj 3088 Easter Holidays(最长路+最短路+打印路径)
摘要:Scandinavians often make vacation during the Easter holidays in the largest ski resort Are. Are provides fantastic ski conditions, many ski lifts and slopes of various difficulty profiles. However, some lifts go faster than others, and some are so popular that a queue forms at the bottom.Per is a be
阅读全文
posted @
2013-11-08 21:31
straw_berry
阅读(347)
推荐(0)
AOE网上的关键路径(最长路径 + 打印路径)
摘要:题目描述 一个无环的有向图称为无环图(Directed Acyclic Graph),简称DAG图。 AOE(Activity On Edge)网:顾名思义,用边表示活动的网,当然它也是DAG。与AOV不同,活动都表示在了边上,如下图所示: 如上所示,共有11项活动(11条边),9个事件(9个顶点)。整个工程只有一个开始点和一个完成点。即只有一个入度为零的点(源点)和只有一个出度为零的点(汇点)。 关键路径:是从开始点到完成点的最长路径的长度。路径的长度是边上活动耗费的时间。如上图所示,1到2到5到7到9是关键路径(关键路径不止一条,请输出字典序最小的),权...
阅读全文
posted @
2013-11-08 17:27
straw_berry
阅读(2338)
推荐(0)
MPI Maelstrom(Dijkstra)
摘要:http://poj.org/problem?id=1502刷一道模板题稳定一下心情。。。Dijkstra求单源最短路,就是输入的时候注意下,是按下三角输入的(无向图),输入字符x表示i与j不通。可以这样输入:if(scanf("%d",&w)) map[i][j] = map[j][i] = w; else scanf("x"); 1 #include 2 #include 3 const int INF = 0x3f3f3f3f; 4 5 int map[110][110],vis[110],dis[110],n; 6 void Dijkst
阅读全文
posted @
2013-11-06 19:41
straw_berry
阅读(288)
推荐(0)
find the safest road(floyd)
摘要:Time Limit: 10000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5183Accepted Submission(s): 1868Problem DescriptionXX星球有很多城市,每个城市之间有一条或多条飞行通道,但是并不是所有的路都是很安全的,每一条路有一个安全系数s,s是在 0 和 1 间的实数(包括0,1),一条从u 到 v 的通道P 的安全度为Safe(P) = s(e1)*s(e2)…*s(ek) e1,e2,ek是P 上的边 ,现在8600
阅读全文
posted @
2013-10-08 16:58
straw_berry
阅读(219)
推荐(0)
find the mincost route(floyd变形 无向图最小环)
摘要:Time Limit: 1000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1630Accepted Submission(s): 664Problem Description杭州有N个景区,景区之间有一些双向的路来连接,现在8600想找一条旅游路线,这个路线从A点出发并且最后回到A点,假设经过的路线为V1,V2,....VK,V1,那么必须满足K>2,就是说至除了出发点以外至少要经过2个其他不同的景区,而且不能重复经过同一个景区。现在8600需要你帮他找一条这样的
阅读全文
posted @
2013-10-07 17:18
straw_berry
阅读(219)
推荐(0)
SDUT 最短路径(二维SPFA)
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2622 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const long long INF = 1LL map[110];12 int inque[110];13 long long dis[110][12];14 int s,t,x,n,m;15 16 void spfa()17 {18 queueque;19 for(int i = 0; ...
阅读全文
posted @
2013-09-09 23:00
straw_berry
阅读(248)
推荐(0)
昂贵的聘礼
摘要:Time Limit:1000MSMemory Limit:10000KTotal Submissions:32063Accepted:9080Description年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:"嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就行了。"探险家就跑到大祭司那里,向他要求皮袄或水晶球,大祭司要他用金币来换,或者替他弄来其他的东西,他可以降低价格
阅读全文
posted @
2013-08-08 19:17
straw_berry
阅读(328)
推荐(0)
Currency Exchange(判断是否有正环)
摘要:Time Limit:1000MSMemory Limit:30000KTotal Submissions:16456Accepted:5732DescriptionSeveral currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can be several point
阅读全文
posted @
2013-08-07 15:57
straw_berry
阅读(282)
推荐(0)
spfa模板
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 const int INF = 0x3f3f3f3f; 9 const int MAX = 10000;10 11 struct edge12 {13 int to,w;14 };15 int n,m;16 int inque[MAX+10];//标记节点是否在队列里17 int dis[MAX+10];//保存最短路径18 int vexcnt[MAX+10];//保存节点进队次数19 vectormap[MAX+10...
阅读全文
posted @
2013-07-31 17:31
straw_berry
阅读(205)
推荐(0)
Wormholes 最短路判断有无负权值
摘要:DescriptionWhile exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination at a time that is BEFORE you entered the wormhole! Each of FJ's farms comprisesN(1 ≤N≤ 500) fields co
阅读全文
posted @
2013-07-29 13:10
straw_berry
阅读(271)
推荐(0)
最小生成树 最短路
摘要:1 View Code 2 3 int prime(int cur) 4 { 5 int index; 6 int sum = 0; 7 memset(visit, false, sizeof(visit)); 8 visit[cur] = true; 9 for(int i = 0; i graph[index][j]){28 dist[j] = graph[index][j];29 } 30 } 31 } 32 return sum; 3...
阅读全文
posted @
2013-06-21 21:39
straw_berry
阅读(132)
推荐(0)
畅通工程续 最短路
摘要:某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处理到文件结束。 每组数据第一行包含两个正整数N和M(0 2 #include 3 int map[200][200],vis[200]; 4 int n,m,s,t; 5 void dijkstra() 6 { 7 int dis[200],i,j; 8 for(i = 0; i z...
阅读全文
posted @
2013-05-05 01:25
straw_berry
阅读(164)
推荐(0)