为什么我的鱼棋一分拿不到QAQ,样例和附加样例都过的,怎么就被hack完了QAQ
#include<bits/stdc++.h>
#define mk make_pair
using namespace std;
const int maxn = 205;
const int Kw[] = {0,1,-1},Bw[] = {1,-1};
const int Nwx[] = {1,1,-1,-1,2,-2,2,-2};
const int Nwy[] = {2,-2,2,-2,1,1,-1,-1};
const int Rwx[] = {0,0,1,-1},Rwy[] = {1,-1,0,0};
int T,n,m,sx,sy,ans; char sta,x;
vector<vector<char> > mp; map<int,map<int,int> > vis;
queue<pair<pair<pair<int,int>,char>,pair<int,int> > > q;
// void change(int x,int y,int st,int tot,char nxt) { q.push(mk(mk(mk(st,tot + 1),nxt),mk(x,y))); }
void move(int x,int y,int st,int tot,char now) { q.push(mk(mk(mk(st,tot),now),mk(x,y))); }
void bfs() { // 恶心死了这题
while (!q.empty()) q.pop();
for (int i = 1;i <= n;i ++)
for (int j = 1;j <= m;j ++)
vis[i][j] = -1;
q.push(mk(mk(mk(0,0),sta),mk(sx,sy))); ans = 1e9;
while (!q.empty()) {
auto top = q.front(); q.pop();
int x = top.second.first, y = top.second.second, st = top.first.first.first,tot = top.first.first.second;
char now = top.first.second;
if (x < 1 || x > n || y < 0 || y > m || (vis[x][y] != -1 && vis[x][y] != st) || mp[x][y] == '#') continue;
// change & move
vis[x][y] = st; if (mp[x][y] == 'T') { ans = min(ans,st + tot); }
if (st + tot >= ans) continue;
for (int i = 0;i < 3;i ++)
for (int j = 0;j < 3;j ++)
if (i != 0 && j != 0)
move(x + Kw[i],y + Kw[j],st + 1,tot + (now != 'K'),'K');
for (int i = 0;i < 2;i ++)
for (int j = 0, nx = x + Bw[i], ny = y + Bw[j];j < 2;j ++, nx = x + Bw[i], ny = y + Bw[j])
while (nx > 0 && nx <= n && ny > 0 && ny <= m && mp[nx][ny] != '#') {
move(nx,ny,st + 1,tot + (now != 'B'),'B');
nx += Bw[i], ny += Bw[j];
}
for (int i = 0;i < 8;i ++) move(x + Nwx[i],y + Nwy[i],st + 1,tot + (now != 'N'),'N');
for (int i = 0,nx = x + Rwx[i],ny = y + Rwy[i];i < 4;i ++,nx = x + Rwx[i], ny = y + Rwy[i])
while (nx > 0 && nx <= n && ny > 0 && ny <= m && mp[nx][ny] != '#') {
move(nx,ny,st + 1,tot + (now != 'R'),'R');
nx += Rwx[i], ny += Rwy[i];
}
}
if (ans == 1e9) ans = -1;
}
int main() {
scanf("%d",&T);
while (T --) {
scanf("%d%d %c",&n,&m,&sta);
getchar();
mp.clear(); mp.push_back({});
for (int i = 1;i <= n;i ++) {
mp.push_back({}); mp[i].push_back('#');
for (int j = 1;j <= m;j ++) {
x = getchar();
mp[i].push_back(x);
if (x == 'S') sx = i, sy = j;
}
getchar();
}
bfs(); printf("%d\n",ans);
}
return 0;
}
真的蚌埠住了