60pts,我太蒻了,找不出错QWQ

P1332 血色先锋队

[记录详情](https://www.luogu.com.cn/record/122315861)
by chair0114 @ 2023-08-23 07:28:21


[评测记录](https://www.luogu.com.cn/record/122294603) ```cpp #include<bits/stdc++.h> using namespace std; int n,m,step[2005][2005],a,b,x,y,sum; bool f[2005][2005]; int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1}; struct XY { int x,y; }; queue<XY>s; void bfs() { while(!s.empty()) { int tx=s.front().x,ty=s.front().y; s.pop(); for(int i=0;i<4;i++) { int nx=tx+dx[i],ny=ty+dy[i]; if(nx<1||nx>n||ny<1||ny>m)continue; if(f[nx][ny])continue; f[nx][ny]++; s.push({nx,ny}); step[nx][ny]=step[tx][ty]+1; sum=max(sum,step[nx][ny]); } } return; } signed main(){ cin>>n>>m; cin>>a>>b; while(a--) { cin>>x>>y; s.push({x,y}); gile(b--) { cin>>x>>y; cout<<step[x][y]<<"\n"; } return 0; } ``` 我用的bfs可以过。还有谷民起真早。 求关
by zyhe2013 @ 2023-08-23 08:22:09


|