首页 > 其他分享 >A. Protect Sheep

A. Protect Sheep

时间:2024-05-15 21:52:07浏览次数:9  
标签:Sheep Protect code int 题解 &&

原题链接

题解

你怎么能在地图都没有输入完成的情况下判断呢?

code

#include<bits/stdc++.h>
using namespace std;
string s[505];
int xx[4]={0,-1,1,0},yy[4]={1,0,0,-1};
int main()
{
    int n,m;
    cin>>n>>m;
    int flag=1;
    for(int i=1;i<=n;i++)
    {
        cin>>s[i];
        s[i]=' '+s[i];

    }

    for(int i=1;i<=n;i++)//错误:你怎么能在地图没有输入完全的情况下判断呢?
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i][j]=='W')
            {
                for(int k=0;k<4;k++)
                {
                    int x1=i+xx[k],y1=j+yy[k];
                    if(x1>=1&&x1<=n&&y1>=1&&y1<=m&&s[x1][y1]=='S') flag=0;
                }
            }
        }
    }
    if(flag)
    {
        puts("Yes");
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {
                if(s[i][j]=='.') cout<<'D';
                else cout<<s[i][j];
            }
            puts("");
        }
    }
    else puts("No");

    return 0;
}


标签:Sheep,Protect,code,int,题解,&&
From: https://www.cnblogs.com/pure4knowledge/p/18194775

相关文章

  • java代码运行出现DENIED Redis is running in protected mode because protected mode
    这个错误是因为开启了保护模式,导致出错。所以需要关闭redis的保护模式。编辑redis的redis.config  注释bind127.0.0.1 、修改protected-mode为no、修改 daemonize为no然后重启redis ......
  • day12_我的Java学习笔记 (package包、权限修饰符_private+缺省+protected+public、fin
    1.包IDEA配置自动导包:2.权限修饰符同一个类中的,【private、缺省、protected、public】都可以访问同一个包中的其他类,【private】不可以访问,【缺省、protected、public】都可以访问不同包下的无关类,【private、缺省、protected】都不可以访问,只有【public......
  • @Degenerate_Sheep
    因为神秘原因翻到了之前的一个......
  • C++继承之protected继承
    1概述  通过继承机制,可以利用已有的对象类型来定义新对象类型。所定义的新对象类型不仅仅拥有新定义的成员,而且还同时拥有旧的成员。我们称已存在的用来派生新类的类为基类,又称为父类。由已存在的类派生出的新类称为派生类,又称为子类。。2对象访问作用域作用域:publi......
  • 加密软件VMProtect教程:使用脚本-功能
    VMProtect是新一代软件保护实用程序。VMProtect支持德尔菲、BorlandCBuilder、VisualC/C++、VisualBasic(本机)、VirtualPascal和XCode编译器。同时,VMProtect有一个内置的反汇编程序,可以与Windows和MacOSX可执行文件一起使用,并且还可以链接编译器创建的MAP文件,以快速选择......
  • Activate Guided Access mode to protect your privacy on iPhone
    Ifyoudon'tintendtosetupanAppLockforspecificapps,isthereasimplerwaytoachievethesamegoal?Theansweriscertainlyyes,andthatisbysettingup[GuidedAccessmode]whichconfinesactivitiestoasingleapp.Thismodeisnotenab......
  • [AGE] Eushully ASProtect 脱壳
    [AGE引擎]EushullyASProtect脱壳AGE引擎的ASProtect主要在2013年左右的版本上,2017年的天結いキャッスルマイスター已经采用了PlayDRM。ASProtect主要加在AGE.EXE和AGERC.DLL上,前者为游戏主程序,后者为游戏的资源DLL(标题菜单,模态窗口),AGERC.DLL容易被加壳软件识别为ASPack,......
  • SPPSVC.EXE(Software Protection Platform Service)是Windows操作系统中的一个进程,起源
    ‪C:\Windows\System32\sppsvc.exeSPPSVC.EXE(SoftwareProtectionPlatformService)是Windows操作系统中的一个进程,起源于微软公司为了保护其软件版权而开发的软件保护服务。这个服务主要负责验证Windows的许可证信息、管理软件激活状态以及执行与软件许可证相关的任务。SPPSVC.E......
  • Java访问权限之public、protected、private详解——【包和访问控制】【访问权限控制】
    @目录包和访问控制包声明和导入访问权限控制源码:Giteehttps://gitee.com/drip123456/java-seGIthubhttps://github.com/Drip123456/JavaSE专栏:JavaSE笔记专栏包和访问控制通过前面的学习,我们知道该如何创建和使用类。包声明和导入包其实就是用来区分类位置的东西,也可......
  • E. Arranging The Sheep
    Thisisaprogramingproblemoncodeforeswithadifficultyscoreof1400.Itpresentsanintrestingchallengethatcanbesolvedusingtheprincipleofgreediness.Initially,it'sevidentthatweneedtomoveeachshapeonebyoneandgatherthemwi......