随笔分类 -  图论

Popular Cows
摘要:DescriptionEvery cow's dream is to become the most popular cow in the herd. In a herd of N (1 1,那么不存在否则输出该点的强连通分量点的个数。#include#include#include#include#includeusing namespace std;int visit[10001];int dfn[10001],low[10001],head[10001],n,m,ret,ans,ti;int flag[10001];stack st;vector v[10001];int du[ 阅读全文

posted @ 2013-10-11 11:15 forevermemory 阅读(297) 评论(0) 推荐(0)

Thrall’s Dream
摘要:We never paid any heed to the ancient prophecies, like fools we clung to the old hatreds, and fought as we had for generations. Until one day the sky rained fire, and a new enemy came upon us. We stand now upon the brink of destruction, for the Reign of Chaos has come at last.Thrall, the warchief of 阅读全文

posted @ 2013-10-11 03:03 forevermemory 阅读(584) 评论(0) 推荐(0)

CX and girls
摘要:Description CX是要赶去上课,为了不迟到必须要以最短的路径到达教室,同时CX希望经过的路上能看到的学妹越多越好。现在把地图抽象成一个无向图,CX从1点出发,教室在N号点,告诉每个点上学妹的数量,每条边的长度。请你求出CX以最短路径赶到教室最多能看到多少学妹。Input 多组输入数据(最多20组),输入到文件结束。 每组数据第一行两个正整数N,M其中N代表点的个数(2#include#include#define MAX 10000000using namespace std;int p[1005][1005];int flag[1005][1005];int visit[1005] 阅读全文

posted @ 2013-10-06 17:38 forevermemory 阅读(300) 评论(0) 推荐(0)

Friends
摘要:Alice lives in the country where people like to make friends. The friendship is bidirectional and if any two person have no less than k friends in common, they will become friends in several days. Currently, there are totally n people in the country, and m friendship among them. Assume that any new 阅读全文

posted @ 2013-10-04 15:55 forevermemory 阅读(216) 评论(0) 推荐(0)

Cab
摘要:题目描述HJ,LWC,HRQ三个人在外面比赛,比赛前他们想去外面玩,但是三个人相去的地方不一样。他们坐一辆出租车,请问怎么走,把他们三个都送到目的地的路程最短?输入第一行是一个整数K(K#include#include#include#include#include#define inf 100000000using namespace std;int visit[1005];int pre[1005];int des[1005];int save[4];int sg[4][4];int n,m;struct lmx{int to;int next;int w;};lmx lm[80004]; 阅读全文

posted @ 2013-09-30 14:32 forevermemory 阅读(353) 评论(0) 推荐(0)

John's trip
摘要:DescriptionLittle Johnny has got a new car. He decided to drive around the town to visit his friends. Johnny wanted to visit all his friends, but there was many of them. In each street he had one friend. He started thinking how to make his trip as short as possible. Very soon he realized that the be 阅读全文

posted @ 2013-09-27 21:54 forevermemory 阅读(286) 评论(0) 推荐(0)

Catenyms
摘要:DescriptionA catenym is a pair of words separated by a period such that the last letter of the first word is the same as the last letter of the second. For example, the following are catenyms:dog.gopher gopher.rat rat.tiger aloha.aloha arachnid.dogA compound catenym is a sequence of three or more wo 阅读全文

posted @ 2013-09-27 16:35 forevermemory 阅读(242) 评论(0) 推荐(0)

Colored Sticks
摘要:DescriptionYou are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a straight line such that the colors of the endpoints that touch are of the same color?InputInput is a sequence of lines, each line contains two words, sep 阅读全文

posted @ 2013-09-25 15:33 forevermemory 阅读(310) 评论(0) 推荐(0)

Strategic Game
摘要:Problem DescriptionBob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following problem. He must defend a medieval city, the roads of which form a tree. He has to put the minimum number of soldi 阅读全文

posted @ 2013-09-18 21:32 forevermemory 阅读(245) 评论(0) 推荐(0)

Girls and Boys
摘要:Problem Descriptionthe second year of the university somebody started a study on the romantic relations between the students. The relation “romantically involved” is defined between one girl and one boy. For the study reasons it is necessary to find out the maximum set satisfying the condition: ther 阅读全文

posted @ 2013-09-18 17:48 forevermemory 阅读(286) 评论(0) 推荐(0)

还是畅通工程
摘要:Problem Description某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。Input测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( #include#include#includeusing namespace std;int p[105],n,sum;void init(){int i;for(i=1;i<=n;i++) p[i]=i;}int find(int x){ 阅读全文

posted @ 2013-09-16 16:39 forevermemory 阅读(135) 评论(0) 推荐(0)

City Tour
摘要:DescriptionAlice想要从城市A出发到城市B,由于Alice最近比较穷(不像集训队陈兴老师是个rich second),所以只能选择做火车从A到B。不过Alice很讨厌坐火车,火车上人比较多,比较拥挤,所以Alice有很严格的要求:火车的相邻两站间的最大距离尽可能的短,这样Alice就可以在停站的时候下车休息一下。当然Alice希望整个旅途比较短。Input有多组测试数据。每组测试数据的第一行有两个整数N,M,A,B(N=2, A,B#include#include#include#define inf 10000000using namespace std;struct lmx{ 阅读全文

posted @ 2013-09-10 10:37 forevermemory 阅读(342) 评论(0) 推荐(0)

Minimum Transport Cost
摘要:Problem DescriptionThese are N cities in Spring country. Between each pair of cities there may be one transportation track or none. Now there is some cargo that should be delivered from one city to another. The transportation fee consists of two parts: The cost of the transportation on the path betw 阅读全文

posted @ 2013-09-06 17:31 forevermemory 阅读(240) 评论(0) 推荐(0)

Arbitrage
摘要:Problem DescriptionArbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 British pound, 1 British pound buys 10.0 French francs, and 1 French franc buys 0.21 US 阅读全文

posted @ 2013-08-29 10:11 forevermemory 阅读(291) 评论(0) 推荐(0)

Choose the best route
摘要:Problem DescriptionOne day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traffic route, and the stations which are near Kiki’s home so that she can take. You may suppose Kiki 阅读全文

posted @ 2013-08-29 00:40 forevermemory 阅读(197) 评论(0) 推荐(0)

最短路
摘要:Problem Description在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗?Input输入包括多组数据。每组数据第一行是两个整数N、M(N#include#includeusing namespace std;const int inf=10000000;int n,m;int p[1005][1005];int visit[1005];int des[1005];int dijkstra(int s){ int i,k,j; 阅读全文

posted @ 2013-08-28 23:27 forevermemory 阅读(141) 评论(0) 推荐(0)

一个人的旅行
摘要:Problem Description虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽的风景……草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽约纯粹看雪景,去巴黎喝咖啡写信,去北京探望孟姜女……眼看寒假就快到了,这么一大段时间,可不能浪费啊,一定要给自己好好的放个假,可是也不能荒废了训练啊,所以草儿决定在要在最短的时间去一个自己想去的地方!因为草儿的家在一个小镇上,没有火车经过,所以她只能去邻近的城市坐火车(好可怜啊~)。I 阅读全文

posted @ 2013-08-28 23:06 forevermemory 阅读(233) 评论(0) 推荐(0)

Jungle Roads
摘要:DescriptionThe Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly, so the large road network is too expensive to maintain. The Council of Elders must choose t 阅读全文

posted @ 2013-08-28 11:24 forevermemory 阅读(195) 评论(0) 推荐(0)

Eddy's picture
摘要:Problem DescriptionEddy begins to like painting pictures recently ,he is sure of himself to become a painter.Every day Eddy draws pictures in his small room, and he usually puts out his newest pictures to let his friends appreciate. but the result it can be imagined, the friends are not interested i 阅读全文

posted @ 2013-04-01 00:05 forevermemory 阅读(144) 评论(0) 推荐(0)