• codeforces 948A


    Protect Sheep

    暴力题

    #include "iostream"
    #include "iomanip"
    #include "string.h"
    #include "stack"
    #include "queue"
    #include "string"
    #include "vector"
    #include "set"
    #include "map"
    #include "algorithm"
    #include "stdio.h"
    #include "math.h"
    #pragma comment(linker, "/STACK:102400000,102400000")
    #define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
    #define mem(a,x) memset(a,x,sizeof(a))
    #define step(x) fixed<< setprecision(x)<<
    #define mp(x,y) make_pair(x,y)
    #define pb(x) push_back(x)
    #define ll long long
    #define endl ("
    ")
    #define ft first
    #define sd second
    #define lrt (rt<<1)
    #define rrt (rt<<1|1)
    using namespace std;
    const ll mod=1e9+7;
    const ll INF = 1e18+1LL;
    const int inf = 1e9+1e8;
    const double PI=acos(-1.0);
    const int N=1e5+100;
    
    int M[550][550], r, c;
    
    int main(){
        cin>>r>>c;
        for(int i=1; i<=r; ++i){
            for(int j=1; j<=c; ++j){
                char cc; cin>>cc;
                if(cc == 'S') M[i][j] = 1;
                else if(cc == 'W') M[i][j] = 2;
            }
        }
        for(int i=1; i<=r; ++i){
            for(int j=1; j<=c; ++j){
                if(M[i][j] == 1){
                    if(M[i][j+1] == 0) M[i][j+1] = 3;
                    else if(M[i][j+1] == 2) return 0*printf("No
    ");
                    if(M[i][j-1] == 0) M[i][j-1] = 3;
                    else if(M[i][j-1] == 2) return 0*printf("No
    ");
                    if(M[i+1][j] == 0) M[i+1][j] = 3;
                    else if(M[i+1][j] == 2) return 0*printf("No
    ");
                    if(M[i-1][j] == 0) M[i-1][j] = 3;
                    else if(M[i-1][j] == 2) return 0*printf("No
    ");
                }
            }
        }
        cout<<"Yes
    ";
        for(int i=1; i<=r; ++i){
            for(int j=1; j<=c; ++j){
                if(M[i][j] == 0) cout<<'.';
                if(M[i][j] == 1) cout<<'S';
                if(M[i][j] == 2) cout<<'W';
                if(M[i][j] == 3) cout<<'D';
            }
            cout<<endl;
        }
        return 0;
    }
  • 相关阅读:
    如何将DataTable转换成List<T>
    关于SqlDataAdapter的使用
    VS 2010中JS代码折叠插件
    ASP.net中的几种分页方法
    学习jquery基础教程的一些笔记
    js中innerHTML与innerText的用法与区别
    SpringBoot 中使用shiro注解使之生效
    redis分布式锁
    使用ZSetOperations(有序)操作redis
    使用SetOperations(无序)操作redis
  • 原文地址:https://www.cnblogs.com/max88888888/p/8592650.html
Copyright © 2020-2023  润新知