题解 CF948A 【Protect Sheep】
额。。这道题亮点在:
$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】的更多相关文章
- [CF] 948A Protect Sheep
A. Protect Sheep time limit per test1 second memory limit per test256 megabytes inputstandard input ...
- 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 ...
- 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 ...
- 【codeforces】【比赛题解】#948 CF Round #470 (Div.2)
[A]Protect Sheep 题意: 一个\(R*C\)的牧场中有一些羊和一些狼,如果狼在羊旁边就会把羊吃掉. 可以在空地上放狗,狼不能通过有狗的地方,狼的行走是四联通的. 问是否能够保护所有的羊 ...
- Codeforces Round #470 Div. 2题解
A. Protect Sheep time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- 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, ...
- 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 ...
- 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 ...
- Funny Sheep(思维)
Problem 1606 - Funny Sheep Time Limit: 1000MS Memory Limit: 65536KB Total Submit: 612 Accepted ...
随机推荐
- elastic(10) 基本查询
# 指定index名以及type名的搜索 GET /library/books/_search?q=title:elasticsearch # 指定index名没有type名的搜索 GET /libr ...
- (转)css 背景色渐变兼容写法
css3:linear-gradient 比如:黑色渐变到白色,代码如下: .gradient{ background: -moz-linear-gradient(top, #000000 0%, # ...
- Maven 国内源
maven的仓库好慢的说,还是配置一个国内的源吧.推荐aliyun 在maven/conf/settings.xml 文件里配置mirrors的子节点,添加如下mirror <mirror> ...
- sendCloud群发邮件一点总结
1.群发时,若发送的邮件为html页面,则不能用[普通发送]然后foreach循环: 若是单纯的文本,则可以用普通发送,否则,第一封邮件成功后,后面的都是html乱码. 2.若要用html模板发送,可 ...
- Java虚拟机(二):垃圾回收算法
一.介绍 GC(Garbage Collection),垃圾收集 Java中,GC的对象是堆空间和永久区 二.GC算法 1. 引用计数法 老牌垃圾回收算法 通过引用计算来回收垃圾 Java中未使用,使 ...
- 有关Lucene的问题(4):影响Lucene对文档打分的四种方式
原文出自:http://forfuture1978.iteye.com/blog/591804点击打开链接 在索引阶段设置Document Boost和Field Boost,存储在(.nrm)文件中 ...
- Mongodb的安装与启动
下载链接: http://www.mongodb.org/downloads ------------------------------------------------------------- ...
- wangEditor富文本编辑器
设置好了是这样的, 有一个ID问content的编辑框,方便获取,这里的富文本编辑器的版本是2.2 官方文档说3就不支持textarea了 导入一下css 记得css文件夹下应该又3个文件,虽然没有直 ...
- C++获取时间并命名为文件名
#include <time.h> char pStrPath1[20];time_t currTime;struct tm *mt;Mat saveImg1; currTime = ti ...
- 面试题:servlet jsp cook session 背1
一.Servlet是什么?JSP是什么?它们的联系与区别是什么? Servlet是Java编写的运行在Servlet容器的服务端程序,狭义的Servlet是指Servlet接口,广义的Servlet是 ...