思路:接BFS判断能否在限制时间内到达公主的位置,注意如果骑士进入传送机就会被立即传送到另一层,不会能再向四周移动了,例如第一层的位置(x, y, 1)是传送机,第二层(x, y, 2)也是传送机,这种情况骑士会一直被传上传下. AC代码: 0ms #include<cstdio> #include<cmath> #include<cstring> #include<queue> using namespace std; const int maxn = 1…
保存每个节点的下一个节点一直往下面走就行了,不能重复经过某个点,当经过的点达到20个而且当前节点的下一个节点是起点就打印答案. AC代码 #include<cstdio> #include<vector> #include<cstring> #include<algorithm> using namespace std; const int maxn = 25; int vis[maxn]; vector<int>v[25]; int ans[m…