Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, each grid of this board is consisting of grass or just empty and then they start to fire all the grass. Firstly they choose two gr
一.求所有顶点到s顶点的最小步数 //BFS宽度优先搜索 #include<iostream> using namespace std; #include<queue> #define MAX 10000 ][],int s,int n)//从(si,sj)出发能到的位置以及距离 { int *flag=new int[n];//顶点是否被遍历过,0未遍历,1已入队,2已出队 int *dist=new int[n]; int i; ;i<n;i++) { flag[i]
宽度优先搜索(BFS) #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> #define x first #define y second using namespace std; typedef pair<int,int> PII; const int N=210; char g[N][N]; int d
Knight Moves Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10542 Accepted Submission(s): 6211 Problem Description A friend of you is doing research on the Traveling Knight Problem (TKP) wh
原题地址 https://vjudge.net/contest/313171 密码:algorithm A - Rescue Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison. Angel's fr