输出呢()

P1746 离开中山路

Miracle_InDream @ 2024-01-02 22:58:48

#include<bits/stdc++.h>
using namespace std;
int n;
char mp[1005][1005];
int vis[1005][1005];
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int a,b,c,d;
struct node
{
    int x;
    int y;
    int step;
};
node s,t;
queue<node> q;
void bfs()
{
    s.x=a;
    s.y=b;
    t.x=c;
    t.y=d;
    s.step=0;
    q.push(s);
    while(!q.empty())
    {
        node tmp=q.front();
        q.pop();
        vis[tmp.x][tmp.y]=1;
        if(tmp.x==c&&tmp.y==d)
        {
            cout<<tmp.step;
            return;
        }
        for(int i=0;i<4;i++)
        {
            node a;
            a.x=tmp.x+dx[i];
            a.y=tmp.y+dy[i];
            a.step=tmp.step+1;
            if(a.x>0&&a.y>0&&a.x<=n&&a.y<=n&&vis[a.x][a.y]==0&&mp[a.x][a.y]==0)
            {
                q.push(a);
            }
        }
    }
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cin>>mp[i][j];
        }
    }
    cin>>a>>b>>c>>d;
    bfs();
    return 0;
}

by _buzhidao_ @ 2024-01-02 23:00:06

@shooting__star 循环/判断没进


by Miracle_InDream @ 2024-01-02 23:01:42

@buzhidao 艹,脑抽了,我在干什么傻*的事情()


by Miracle_InDream @ 2024-01-02 23:04:22

什么鬼怎么TLE成这副德行了,一开O2送我一堆MLE/kk


by _buzhidao_ @ 2024-01-02 23:06:21

@shooting__star 有没有亿种可能,您深搜炸了


by ICU152_QWQ_IS8 @ 2024-01-02 23:06:54

@shooting__star 没看题,但你判断mo确定没错?


by _buzhidao_ @ 2024-01-02 23:07:05

@buzhidao 口误,广搜


by Miracle_InDream @ 2024-01-02 23:07:25

@buzhidao ???哥们我写的是广搜()


by ICU152_QWQ_IS8 @ 2024-01-02 23:07:44

mo->mp


by Miracle_InDream @ 2024-01-02 23:08:36

@ISU152_YYDS 那你还是先看题吧,鬼知道()


by ICU152_QWQ_IS8 @ 2024-01-02 23:10:20

@shooting__star mp i j == 0 应该是'0'吧


| 下一页