zoukankan      html  css  js  c++  java
  • 第一次的迷宫为队列版,这个为搜索版x(自己写的嘿嘿)

    错误原因:第一次提交的时候把Yes跟No输错了都输为大写:……

    代码来啦!

    #include<cstdio>
    #include<iostream>
    
    using namespace std;
    
    int m,n,tot;
    int jz[2020][2020];
    bool j[2020][2020];//初始为0
    
    void ym(int x,int y) {
        j[x][y]=1;
        if(!j[x+1][y]&&jz[x+1][y]<=jz[x][y]&&x+1<=n) {
            ym(x+1,y);
            tot--;
        }
        if(!j[x][y+1]&&jz[x][y+1]<=jz[x][y]&&y+1<=m) {
            ym(x,y+1);
            tot--;
        }
        if(!j[x-1][y]&&jz[x-1][y]<=jz[x][y]&&x-1>0) {
            ym(x-1,y);
            tot--;
        }
        if(!j[x][y-1]&&jz[x][y-1]<=jz[x][y]&&y-1>0) {
            ym(x,y-1);
            tot--;
        }
    }
    
    void mm(int x1,int y1) {
        if(j[x1][y1]) printf("Yes
    ");
        else printf("No
    ");
    }
    
    int main() {
    
        scanf("%d%d",&n,&m);
        tot=n*m-1;
        for(int i=1; i<=n; ++i) {
            for(int j=1; j<=m; ++j) {
                scanf("%d",&jz[i][j]);
            }
        }
        int sx,sy;
        scanf("%d%d",&sx,&sy);
        j[sx][sy]=1;//进行标记,已经被淹没
        ym(sx,sy);
        printf("%d
    ",tot);
        int q,xw,yw;
        scanf("%d",&q);
        for(int k=1; k<=q; ++k) {
            scanf("%d%d",&xw,&yw);
            mm(xw,yw);
        }
    
        return 0;
    }

    如果运气好也是错,那我倒愿意错上加错!

    ❀❀❀❀❀❀❀❀❀❀❀❀❀❀❀❀❀❀❀❀❀

  • 相关阅读:
    Spring 注解@Transactional
    数据库中为什么要建立视图,它有什么好处?
    类、抽象类与接口的区别
    Comparable和Comparator的区别?
    jetty安装
    python 命令行参数sys.argv
    python--用户认证登录实现
    python--查询员工信息
    python基础
    python学习之路---编程风格规范
  • 原文地址:https://www.cnblogs.com/zxqxwnngztxx/p/6679840.html
Copyright © 2011-2022 走看看