题目链接

额。。这道题亮点在:

$you$ $do$ $not$ $need$ $to$ $minimize$ $their$ $number.$

所以说嘛。。。

直接判断狼的四周有没有紧挨着的羊,没有的话,就直接空地全填狗输出。
有的话就无解。之后就没了。。。很暴力。。。

不过如果你问怎么做才能保证狗最少的话。。。。

貌似是网络流。
反正我不会。

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
char map[][];
int r,c;
int main()
{
scanf("%d%d",&r,&c);
for(int i=;i<=r;i++)
for(int j=;j<=c;j++)
cin>>map[i][j];//输入 for(int i=;i<=r;i++)
for(int j=;j<=c;j++)
{
if(map[i][j]=='S')
{
if(map[i-][j]=='W'||map[i][j-]=='W'||map[i+][j]=='W'||map[i][j+]=='W')//判断
{
printf("No");
return ;
}
}
}
printf("Yes\n");
for(int i=;i<=r;i++,puts(""))
for(int j=;j<=c;j++)
{
if(map[i][j]=='.') printf("D");//如果是空地,则全变成狗。
else printf("%c",map[i][j]);//输出。
}
return ;//程序拜拜。 }
/*
6 6
..S...
..S.W.
.S....
..W...
...W..
...... DDSDDD
DDSDWD
DSDDDD
DDWDDD
DDDWDD 1 2
SW */

题解 CF948A 【Protect Sheep】的更多相关文章

  1. [CF] 948A Protect Sheep

    A. Protect Sheep time limit per test1 second memory limit per test256 megabytes inputstandard input ...

  2. Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1)A. Protect Sheep

    http://codeforces.com/contest/948/problem/A   A. Protect Sheep Bob is a farmer. He has a large pastu ...

  3. Codeforces Round #470 (Div. 2) A Protect Sheep (基础)输入输出的警示、边界处理

    Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to w ...

  4. 【codeforces】【比赛题解】#948 CF Round #470 (Div.2)

    [A]Protect Sheep 题意: 一个\(R*C\)的牧场中有一些羊和一些狼,如果狼在羊旁边就会把羊吃掉. 可以在空地上放狗,狼不能通过有狗的地方,狼的行走是四联通的. 问是否能够保护所有的羊 ...

  5. Codeforces Round #470 Div. 2题解

    A. Protect Sheep time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  6. VK Cup 2018 - Round 1+Codeforces Round #470

    A. Primal Sport 题意:有两个人轮流玩游戏.给出数X(i-1),轮到的人需要找到一个小于X(i-1)的素数x,然后得到Xi,Xi是x的倍数中大于等于X(i-1)的最小的数.现在已知X2, ...

  7. Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1)

    A. Protect Sheep time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  8. hdu 3046 Pleasant sheep and big big wolf 最小割

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3046 In ZJNU, there is a well-known prairie. And it a ...

  9. Funny Sheep(思维)

    Problem 1606 - Funny Sheep Time Limit: 1000MS   Memory Limit: 65536KB    Total Submit: 612  Accepted ...

随机推荐

  1. java成神之——接口,泛型,类

    接口 接口定义 默认方法 函数式接口 泛型 泛型类 泛型类继承 类型限定 泛型方法 泛型接口 类 构造函数 类的继承 抽象类 instanceof运算符 内部类 equals 结语 接口 接口定义 j ...

  2. 转摘:ashx+jquery-autocomplete文本框输入提示功能Asp.net

    引入所需文件 <script type="text/javascript" src="JS/jquery-1.8.2.min.js"></sc ...

  3. leetcode583

    public class Solution { public int MinDistance(string word1, string word2) { , word2.Length + ]; ; i ...

  4. Flask 上下文(Context)原理解析

    :first-child { margin-top: 0; } blockquote > :last-child { margin-bottom: 0; } img { border: 0; m ...

  5. 供参考的 php 学习路线

    供参考的 php 学习路线   第一阶段第一讲,WEB基础     1.1 网站基本知识: 1.2 网络协议介绍: 1.3 B/S与C/S结构的区别: 1.4 WEB编程.网站开发技术介绍.      ...

  6. ubuntu14.04 使用笔记

    这是第二次安装使用ubuntu了,虽然上一次因为不习惯和不会使用一两天就放弃了,这次坚持的时间稍微长一点,目前ubuntu的基本使用也熟悉了.但是由于ubuntu上的应用太少,常用软件,比如QQ,Ph ...

  7. AntD01 Angular2整合AntD、Angular2整合Material、利用Angular2,AntD,Material联合打造后台管理系统 ???

    待更新... 2018-5-21 13:53:52 1 环境说明 2 搭建Angular项目 详情参见 -> 点击前往 辅助技能 -> 点击前往 3 创建共享模块 ng g m share ...

  8. 数字图像处理实验(12):PROJECT 05-03,Periodic Noise Reduction Using a Notch Filter 标签: 图像处理MATLAB 2017-0

    实验要求: Objective: To understand the principle of the notch filter and its periodic noise reducing abi ...

  9. lambda,map,filter,reduce

    lambda 编程中提到的 lambda 表达式,通常是在需要一个函数,但是又不想费神去命名一个函数的场合下使用,也就是指匿名函数.返回一个函数对象. func = lambda x,y:x+y fu ...

  10. Yii2中ACF和RBAC

    ACF ( Access Control Filter) ACF ( Access Control Filter)官网的解释就是一个可以在模型或控制器执行行为过滤器,当有用户请求时,ACF将检查acc ...