我们分成两条路,一条路没有钥匙,一条路有钥匙 来表示状态,让这两条路BFS 不需要考虑多把钥匙的情况,拿到任意一把钥匙就可以 #include <bits/stdc++.h> using namespace std; #define int long long char mp[501][501]; int dist[501][501][2]; int xx[]={0,0,1,-1}; int yy[]={1,-1,0,0}; int n,m; int ex,ey; int tx,ty; bool vis[501][501][2]; struct node{ int x; int y...