上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 21 下一页
这题做的一把鼻涕一把泪,果断考虑不周555Problem Description推箱子是一个很经典的游戏.今天我们来玩一个简单版本.在一个M*N的房间里有一个箱子和一个搬运工,搬运工的工作就是把箱子推到指定的位置,注意,搬运工只能推箱子而不能拉箱子,因此如果箱子被推到一个角上(如图2)那么箱子就不能再被移动了,如果箱子被推到一面墙上,那么箱子只能沿着墙移动.现在给定房间的结构,箱子的位置,搬运工的位置和箱子要被推去的位置,请你计算出搬运工至少要推动箱子多少格.Input输入数据的第一行是一个整数T(1 2 #include 3 using namespace std; 4 const ... Read More
posted @ 2013-07-24 13:11 瓶哥 Views(338) Comments(0) Diggs(0) Edit
1 const int MAX_VERTEX_NUM = 100; //最大顶点数为100 2 3 typedef struct EdgeNode //边表结点 4 { 5 int adjvex; //该边指向的顶点在顺序表中的位置 6 int weight; //边上的权重 7 struct EdgeNode* next; //下一条边 8 }EdgeNode; ... Read More
posted @ 2013-07-19 14:32 瓶哥 Views(177) Comments(0) Diggs(0) Edit
STL的堆操作STL里面的堆操作一般用到的只有4个:make_heap();、pop_heap();、push_heap();、sort_heap();他们的头文件函数是#include 首先是make_heap();函数原型是:void make_heap(first_pointer,end_pointer,compare_function);一个参数是数组或向量的头指针,第二个向量是尾指针。第三个参数是比较函数的名字。在缺省的时候,默认是大跟堆。(下面的参数都一样就不解释了)作用:把这一段的数组或向量做成一个堆的结构。范围是(first,last)然后是pop_heap();它的函数原型是 Read More
posted @ 2013-07-19 13:28 瓶哥 Views(641) Comments(0) Diggs(0) Edit
Problem Description某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处理到文件结束。 每组数据第一行包含两个正整数N和M(0 2 const int MAX = 10000; 3 int n,m,map[200][200]; 4 5 int Dijkstra(int s,int e) 6 { 7 if(s==e) 8 ... Read More
posted @ 2013-07-18 15:59 瓶哥 Views(207) Comments(0) Diggs(0) Edit
1 #include 2 const int MAX = 1<<20; 3 int main() 4 { 5 int n,m,p,q,l; 6 while(~scanf("%d%d",&n,&m),n||m) 7 { 8 int map[101][101], mark[101]={0}; 9 for(int i=1; i<=n; i++)10 {11 for(int j=1; j<=n; j++)12 {13 map[i][j] = MAX; //初始化每条... Read More
posted @ 2013-07-18 13:56 瓶哥 Views(2511) Comments(0) Diggs(0) Edit
Problem DescriptionIgnatius bought a land last week, but he didn't know the area of the land because the land is enclosed by a parabola and a straight line. The picture below shows the area. Now given all the intersectant points shows in the picture, can you tell Ignatius the area of the land?No Read More
posted @ 2013-07-17 16:48 瓶哥 Views(418) Comments(0) Diggs(0) Edit
这个速度比分步快一点,内存占的稍微多一点Problem DescriptionSolitaire is a game played on a chessboard 8x8. The rows and columns of the chessboard are numbered from 1 to 8, from the top to the bottom and from left to right respectively. There are four identical pieces on the board. In one move it is allowed to: > mov Read More
posted @ 2013-07-17 14:55 瓶哥 Views(333) Comments(0) Diggs(0) Edit
Problem DescriptionSolitaire is a game played on a chessboard 8x8. The rows and columns of the chessboard are numbered from 1 to 8, from the top to the bottom and from left to right respectively.There are four identical pieces on the board. In one move it is allowed to:> move a piece to an empty Read More
posted @ 2013-07-17 12:55 瓶哥 Views(255) Comments(0) Diggs(0) Edit
Problem DescriptionSolitaire is a game played on a chessboard 8x8. The rows and columns of the chessboard are numbered from 1 to 8, from the top to the bottom and from left to right respectively.There are four identical pieces on the board. In one move it is allowed to:> move a piece to an empty Read More
posted @ 2013-07-16 22:13 瓶哥 Views(254) Comments(0) Diggs(0) Edit
Map是c++的一个标准容器,她提供了很好一对一的关系,在一些程序中建立一个map可以起到事半功倍的效果,总结了一些map基本简单实用的操作!1.map最基本的构造函数;mapmapstring; mapmapint; mapmapstring; mapmapchar; mapmapchar; mapmapint;2. map添加数据;map maplive; maplive.insert(pair(102,"aclive")); maplive.insert(map::value_type(321,"hai")); maplive[112]=" Read More
posted @ 2013-07-16 14:09 瓶哥 Views(220) Comments(0) Diggs(0) Edit
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 21 下一页