坑爹题,两种输入输出互相交换,裸bfs #include <stdio.h> #include <string.h> typedef struct { int x; int y; } point; point q[310]; int vis[15][15],mat[15][15]; int dx[4]= {1,0,-1,0}; int dy[4]= {0,1,0,-1}; char ans[5]= {"RTLB"}; int bfs1(int x,int y)…
题目链接:http://poj.org/problem?id=3984 Description 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, }; 它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线. Input 一个5 × 5的二维数组,表示一个迷宫.数据保证有…
BFS 简单题套路 1. 遇到迷宫之类的简单题,有什么行走方向的,先写下面的 声明 ; struct Status { int r, c; Status(, ) : r(r), c(c) {} // int DIR; }; int N; //迷宫数量 int W; //迷宫宽度 char map[maxn][maxn]; //地图 //方向 : 分别代表 上.右.下.左向量 ][] = { {-, }, {, }, {, }, {, -} }; bool vis[maxn][maxn]; //队…
You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south, east, west, up or down. You cannot move diagonal…
点我看题目 题意  : 这个人在左下角,地铁在右上角,由很多格子组成的地图,每一条边都是一条路,每一条边都是100米.还有的可以走对角线,问你从起点到终点最短是多少. 思路 : 其实我想说一下,,,,,这个题基本都是用DP做的,这是为什么呢?好吧,这要从我最近要刷BFS题开始,于是二货自己很厉害的用BFS做完了,所以就给我推荐了,我其实没看出来能用BFS来做....... //URAL 1119 #include <iostream> #include <stdio.h> #inc…
Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message, profes…
原题链接 思路:水题,直接搜 #include "map" #include "queue" #include "math.h" #include "stdio.h" #include "string.h" #include "iostream" #include "algorithm" #define abs(x) x > 0 ? x : -x #define…
宽搜基础题 思路很简单,注意细节. 走过的节点一定要打上标记//tag数组 三维字符串输入一定要注意 #include <stdio.h> #include <iostream> #include <string> #include <algorithm> #include <string> #include <string.h> #include <math.h> #include <queue> #defi…
1008 没营养的破题 #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<stdlib.h> #include<queue> using namespace std; typedef struct node { int x,y; }st; ][],w[][]; ],dis[][] = {{,},{,},{-,},{,-…
Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 88732   Accepted: 27795 Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,00…