Description "Hike on a Graph" is a game that is played on a board on which an undirected graph is drawn. The graph is complete and has all loops, i.e. for any two locations there is exactly one arrow between them. The arrows are coloured. There…
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=85 http://poj.org/problem?id=1130 这两个题只有输入输出形式不一样.ZOJ的麻烦一点,这里用的ZOJ的输入输出方式 解题报告: 1.输入方式sscanf(line,"%d%d",&a,&b);表示在文本line中提取两个整形数据到a,b中 2.从外星人的角度来看,就是搜索单源最短路径,采用的方式是广搜. 3.删…
题目连接:problemId=542" target="_blank">ZOJ 1542 POJ 1861 Network 网络 Network Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Andrew is working as system administrator and is planning to establish a new network in his com…
此题是道bfs搜索的题目.bfs的精髓就是找到下一步的所有可能然后存储起来,有点暴力的感觉,这题就是每步中 所有的可能都入队,然后一一 判断.这道题的题意是 : 给你一幅完全图,再给你三个盘,目的是把这三个盘移动到一个点上,输出最少步数!盘移动的时候有要求,比如移第一个盘,把1盘移动到2这个位置,(1,2)这个点有颜色标记,另外两个盘比如说在3,4两点,那么1盘能移动到2这个点的条件是(1,2)这个点的颜色要与(3,4)这点的颜色相同!! #include"iostream" #inc…
  POJ 3126  Prime Path Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16204   Accepted: 9153 Description The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change…
POJ 1426   Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 25734   Accepted: 10613   Special Judge Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representati…
点击打开链接 Borg Maze Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7097   Accepted: 2389 Description The Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used t…
题目 以前做过,所以现在觉得很简单,需要剪枝,注意广搜的特性: 另外题目中,当人在牛的前方时,人只能后退. #define _CRT_SECURE_NO_WARNINGS //这是非一般的最短路,所以广搜到的最短的路不一定是所要的路线 //所以应该把所有的路径都搜索出来,找到最短的转折数,看他是不是不大于2 //我是 用边搜索边更新当前路径的最小转弯数 来写的 #include<stdio.h> #include<string.h> #include<math.h> #…
Description You are given two pots, having the volume of A and B liters respectively. The following operations can be performed: FILL(i) fill the pot i ( ≤ i ≤ ) from the tap; DROP(i) empty the pot i to the drain; POUR(i,j) pour from pot i to pot j;…
主要是学一下如何在广搜中记录路径:每找到一个点我就记录下这个点是由那个点得来的,这样我找到最后个点后,我就可以通过回溯得到我走过的路径,具体看代码吧~ #include<cstdio> #include<stdio.h> #include<cstdlib> #include<cmath> #include<iostream> #include<algorithm> #include<cstring> #include<…