acgo题库
  • 首页
  • 题库
  • 题单
  • 竞赛
  • 讨论
  • 排行
  • 团队
  • 备赛专区

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
登录
注册
题目详情题解(0)讨论(0)提交记录(0)
  • 深搜dfs栈stack 题解100%AC

    userId_undefined

    飞的智动

    题解仙人时空双修者模拟·模拟练习生7月全勤卷王秩序白银快乐小狗
    12阅读
    0回复
    2点赞
  • 题目方向说明

    题目没有说明当有多个解的时候,应该遵循什么方向。 经过N次测试,发现是:下右上左

    userId_undefined

    ID眼见

    7月全勤卷王空间掌握者荣耀黄金循环·循环打卡人字符串·魔法使快乐小狗
    22阅读
    0回复
    0点赞
  • tj

    #include<bits/stdc++.h> using namespace std; int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1}; int n,m,a[1010][1010],sx,sy,fx,fy; char b[1010][1010]; bool vis[1010][1010],flag; struct xy{ int x,y; }; stack<xy>pxy; stack<xy>npxy; void dfs(int x,int y){ if(xfx&&yfy){ while(!pxy.empty()){ npxy.push(pxy.top()); pxy.pop(); } while(!npxy.empty()){ cout<<npxy.top().x-1<<" "<<npxy.top().y-1<<endl; npxy.pop(); } flag=1; return; } pxy.push({x,y}); vis[x][y]=1; for(int i=0;i<4;i++){ int nx=x+dx[i],ny=y+dy[i]; if(nx<1||ny<1||nx>n||ny>m||vis[nx][ny]||a[nx][ny]) continue; else{ dfs(nx,ny); } } vis[x][y]=0; pxy.pop(); } int main() { cin>>n>>m; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>b[i][j]; if(b[i][j]'X') a[i][j]=1; if(b[i][j]'S') sx=i,sy=j; if(b[i][j]=='T') fx=i,fy=j; } } vis[sx][sy]=1; dfs(sx,sy); if(flag)cout<<fx-1<<" "<<fy-1<<endl; if(flag)cout<<"YES"; else cout<<"NO"; return 0; }

    userId_undefined

    AAA秋褲批發lexora_哥

    小有名气题解仙人时空双修者秩序白银传道者
    4阅读
    0回复
    1点赞
首页