题目链接

额。。这道题亮点在:

$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 */

最新文章

  1. 线段树或树状数组---Flowers
  2. Java中的接口与抽象类
  3. eclipse template里面的${user}更改
  4. [转]ORACLE 异常错误处理
  5. struts2笔记05-ServletActionContext
  6. js基本框架
  7. DigitalOcean VPS简介
  8. Python入门(2)
  9. C#打印机操作类
  10. $.isPlainObject
  11. Generative Adversarial Nets[LSGAN]
  12. HTTP 错误 500.21 - Internal Server Error 处理程序“BlockViewHandler”在其模块列表中有一个错误模块“ManagedPipelineHandler
  13. linux 执行远程linux上的shell脚本或者命令以及scp 上传文件到ftp--免密码登陆
  14. PCL点云配准(2)
  15. array_diff、array_diff_key、array_diff_ukey、array_diff_assoc、array_diff_uassoc 的用法
  16. 并查集 - UVALive 6889 City Park
  17. iOS开发之 -- bundle程序束的制造
  18. VINS(五)非线性优化与在线标定调整
  19. angular的过滤器
  20. 【转】vector中对象指针的排序

热门文章

  1. php写一个判断是否有cookie的脚本
  2. CentOS7上elasticsearch5.5启动报错
  3. Springboot热部署(热部署原理)和用IDEA开发需要的配置
  4. linux之sort用法
  5. typedef&amp;nbsp;struct与struct的区别
  6. python3.3 MD5
  7. Physics Material
  8. SpringMVC总结三:请求Controller返回视图类型以及请求方式、参数介绍
  9. EKF model&amp;realization
  10. opennebula 发送序列化ID,构造json格式错误