摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2680一直在纠结时间相等时入队列的先后问题,突然发现自己二呀,路径相等的都会依次入队啊~~~好了,说正事,最短路问题,用Dijkstra,注意几个地方:1.这个问题可以倒过来想,从终点到这几个点中的最短距离。2.路是有向的,如果倒过来想问题,那么路的方向也要倒过来。eg: 输入1 2 5即从1到2的时间是5,那么如果倒过来考虑(以她朋友的家为起点),就要记录w[2][1]=5;源代码: 1 #include 2 #include 3 #include 4 #include 5 using namesp. 阅读全文
posted @ 2013-08-07 16:06 小の泽 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1869最短路问题,没什么好说的,果断Floyd,直接上代码。源代码: 1 #include 2 #include 3 4 using namespace std; 5 const int INF=100000; 6 int d[105][105]; 7 int main() 8 { 9 int n,m,i,j,k,temp_1,temp_2,ok;10 while(scanf("%d %d",&n,&m)!=EOF){11 ok=1;12 for(i=0;id... 阅读全文
posted @ 2013-08-07 10:55 小の泽 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1874这题用Floyd比较方便,一般结点数在300以下的都可以用Floyd.说一下需要注意的地方:1.题目的意思说每两个结点可能有多条路,所以输入两结点的距离的时候要考虑是不是比之前可能输入过的距离短。2.询问可能出现起点和终点是同一点的情况。源代码: 1 #include 2 #include 3 #define max 10000000 4 using namespace std; 5 int d[105][105]; 6 int main() 7 { 8 int n,m,i,j,k,s,e... 阅读全文
posted @ 2013-08-07 10:11 小の泽 阅读(86) 评论(0) 推荐(0) 编辑
摘要: DescriptionThe SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how many quadruplet (a, b, c, d ) ∈ A x B x C x D are such that a + b + c + d = 0 . In the following, we assume that all lists have the same size n .InputThe first line of the input file c 阅读全文
posted @ 2013-08-06 00:58 小の泽 阅读(139) 评论(0) 推荐(0) 编辑
摘要: DescriptionFarmer John is an astounding accounting wizard and has realized he might run out of money to run the farm. He has already calculated and recorded the exact amount of money (1 ≤ moneyi ≤ 10,000) that he will need to spend each day over the next N (1 ≤ N ≤ 100,000) days.FJ wants to create a 阅读全文
posted @ 2013-08-06 00:55 小の泽 阅读(114) 评论(0) 推荐(0) 编辑
摘要: DescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous square plots. It then analyzes each plot separately, using sensing e 阅读全文
posted @ 2013-08-06 00:52 小の泽 阅读(155) 评论(0) 推荐(0) 编辑
摘要: There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles.Write a program to count the number of blac 阅读全文
posted @ 2013-08-06 00:49 小の泽 阅读(238) 评论(0) 推荐(0) 编辑
摘要: DescriptionOne day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as lines, drinks another cup o 阅读全文
posted @ 2013-08-06 00:46 小の泽 阅读(234) 评论(0) 推荐(0) 编辑
摘要: Description一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。Input前20行的第i行有3个数,表示与第i个城市相邻的3个城市.第20行以后每行有1个数m,m=1.m=0退出.Output输出从第m个城市出发经过每个城市1次又回到m的所有路线,如有多条路线,按字典序输出,每行1条路线.每行首先输出是第几条路线.然后个一个: 后列出经过的城市.参看Sample outputSample Input2 5 201 3 122 4 103 5 81 4 65 7 196 8 174 7 98 10 163 9 1110 阅读全文
posted @ 2013-08-06 00:42 小の泽 阅读(155) 评论(0) 推荐(0) 编辑
摘要: time limit per test1 secondmemory limit per test256 megabytesYou are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from top to bottom, 阅读全文
posted @ 2013-08-06 00:39 小の泽 阅读(235) 评论(0) 推荐(0) 编辑