help 27行报错了
查看原帖
help 27行报错了
990278
NEGATUIVE_SEVEN_DL楼主2023/8/16 09:59
#include <bits/stdc++.h>
using namespace std;
struct pos
{
    int x,y;
};
int T,n,book[1250][1250],arr[1250][1250],ti[1250][1250];
queue <pos> q;
int posx[4]={1,-1,0,0};
int posy[4]={0,0,1,-1};
void bfs(int x,int y)
{
    book[x][y]=1;
    pos u;
    u.x=x;
    u.y=y;
    q.push(u);
    while(q.empty()==0)
    {
        pos v=q.front();
        if(v.x==n&&v.y==n)
        {
            cout<<"yes"<<endl;
        }
        for(int i=0;i<4;i++)
        {
            int a=t.x+posx[i];
            int b=t.y+posy[i];
            if(a>=1&&a<=n&&b>=1&&b<=n&&book[a][b]==0)
            {
                book[a][b]=1;
                pos t;
                t.x=a;
                t.y=b;
                q.push(t);
            }
        }
        q.pop();
    }
    cout<<"no"<<endl;
}
int main()
{
    memset(arr,0,sizeof(arr));
    memset(book,0x3f,sizeof(book));
    cin>>T;
    while(T--)
    {
        cin>>n;
        for(int j=1;j<=2*n-2;j++)
        {
            int x,y;
            cin>>x>>y;
            ti[x][y]=1;
        }
        bfs(1,1);
    }
    return 0;
}
2023/8/16 09:59
加载中...