题意:中文;
思路:其实和我访问量最高的那篇哈利波特偷宝藏有点类似,因为需要在回去所以我直接TSP写了,首先抽点建图,只走最短路,存到dis[i][j]数组,表示的是从第i个点到第j个点的最短距离(利用bfs求一哈),之后就抽象出我有n个城市,每次只能走一遍,走完全程在回到起点的最短距离是多少(TSP问题)
上代码把;
#include <bits/stdc++.h>
using namespace std;
#define inf 9999999
struct node
{
int x,y;
int stept;
}b[11];
int bz[10][2] = {0,7,1,6,2,4,3,1,3,8,4,4,6,8,7,6,8,1,9,6},vis[11][11];
int dis[100][100];
int dir[4][2] = {1,0,-1,0,0,1,0,-1},dp[20][1<<15];
int Map[10][10]=
{
{0,0,0,0,0,0,0,1,0,0},
{0,0,0,2,0,0,1,0,0,0},
{0,2,0,0,1,0,0,2,0,0},
{0,1,0,0,0,2,0,0,1,0},
{0,2,0,0,1,0,2,0,0,0},
{0,0,2,0,0,0,0,2,0,0},
{0,0,0,0,0,2,0,0,1,0},
{0,2,0,2,0,0,1,0,0,0},
{0,1,0,0,0,0,2,2,0,0},
{0,0,2,0,0,2,1,0,0,0}
};
int check(int x,int y)
{
if(x<0||y<0||x>=11||y>=11)
{
return 0;
}
if(vis[x][y])
{
return 0;
}