题目链接
很适合做bfs模板题的一道题,用stl中的队列和pair解决.
要是不看题解我就写成深搜了
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
queue<pair<int,int> > q;//队列,存待跳结果
int ans[N][N];//存步数
const int dx[8] = {
-1,-2,-2,-1,1,2,2
很适合做bfs模板题的一道题,用stl中的队列和pair解决.
要是不看题解我就写成深搜了
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
queue<pair<int,int> > q;//队列,存待跳结果
int ans[N][N];//存步数
const int dx[8] = {
-1,-2,-2,-1,1,2,2