题解 CF948A 【Protect Sheep】
2024-10-09 06:59:40
额。。这道题亮点在:
$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 */
最新文章
- 线段树或树状数组---Flowers
- Java中的接口与抽象类
- eclipse template里面的${user}更改
- [转]ORACLE 异常错误处理
- struts2笔记05-ServletActionContext
- js基本框架
- DigitalOcean VPS简介
- Python入门(2)
- C#打印机操作类
- $.isPlainObject
- Generative Adversarial Nets[LSGAN]
- HTTP 错误 500.21 - Internal Server Error 处理程序“BlockViewHandler”在其模块列表中有一个错误模块“ManagedPipelineHandler
- linux 执行远程linux上的shell脚本或者命令以及scp 上传文件到ftp--免密码登陆
- PCL点云配准(2)
- array_diff、array_diff_key、array_diff_ukey、array_diff_assoc、array_diff_uassoc 的用法
- 并查集 - UVALive 6889 City Park
- iOS开发之 -- bundle程序束的制造
- VINS(五)非线性优化与在线标定调整
- angular的过滤器
- 【转】vector中对象指针的排序