Codeforces Round #297 (Div. 2) D Arthur and Walls(bfs)

要理解成本中心与利润中心的根本区别与适用场景,需从 “责任范围、考核核心、管理目标” 三个核心维度切入,同时明确二者在企业管理体系中的联动关系 摘要: 成本中心与利润核心区别在于责任范围、考核目标和管理权限。成本中心仅对成本负责(如生产、行政部门),考核成本控制能力;利润中心需同时管控成本与收入(如独立产品线、区域分公司),以利润为核心指标。选择标准取决于单元是否拥有收入决策权:无收入权的支持/执行部门设为成本中心,能独立经营、核算盈亏的单元设为利润中心。二者协同运作,成本中心为利润中心提供基础支持,利润中心的需求动态影响成本中心资源配置,共同实现企业整体目标。划分本质是确保考核指标与责任范围匹配,避免管理失效。 阅读详情

D. Arthur and Walls
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

Finally it is a day when Arthur has enough money for buying an apartment. He found a great option close to the center of the city with a nice price.

Plan of the apartment found by Arthur looks like a rectangle n × m consisting of squares of size 1 × 1. Each of those squares contains either a wall (such square is denoted by a symbol "*" on the plan) or a free space (such square is denoted on the plan by a symbol ".").

Room in an apartment is a maximal connected area consisting of free squares. Squares are considered adjacent if they share a common side.

The old Arthur dream is to live in an apartment where all rooms are rectangles. He asks you to calculate minimum number of walls you need to remove in order to achieve this goal. After removing a wall from a square it becomes a free square. While removing the walls it is possible that some rooms unite into a single one.

Input

The first line of the input contains two integers n, m (1 ≤ n, m ≤ 2000) denoting the size of the Arthur apartments.

Following n lines each contain m symbols — the plan of the apartment.

If the cell is denoted by a symbol "*" then it contains a wall.

If the cell is denoted by a symbol "." then it this cell is free from walls and also this cell is contained in some of the rooms.

Output

Output n rows each consisting of m symbols that show how the Arthur apartment plan should look like after deleting the minimum number of walls in order to make each room (maximum connected area free from walls) be a rectangle.

If there are several possible answers, output any of them.

Sample test(s)
input
5 5
.*.*.
*****
.*.*.
*****
.*.*.
output
.*.*.
*****
.*.*.
*****
.*.*.
input
6 7
***.*.*
..*.*.*
*.*.*.*
*.*.*.*
..*...*
*******
output
***...*
..*...*
..*...*
..*...*
..*...*
*******
input
4 5
.....
.....
..***
..*..
output
.....
.....
.....
.....


题意: .表示空地,要去掉最少的*使得.围成的每一个块都是矩形


思路:对于每一个*,什么情况下是需要去掉的呢? 将 L,每次旋转90度的形状是需要去掉的,那么每次去掉一个 *,检查是否还需要去掉*





#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>


#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define MID(x,y) ((x+y)>>1)

#define eps 1e-8
typedef __int64 ll;

#define fre(i,a,b)  for(i = a; i <b; i++)
#define free(i,b,a) for(i = b; i >= a;i--)
#define mem(t, v)   memset ((t) , v, sizeof(t))
#define ssf(n)      scanf("%s", n)
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pf          printf
#define bug         pf("Hi\n")

using namespace std;

#define INF 0x3f3f3f3f
#define N 2005

int n,m;
char a[N][N];
typedef pair<int,int>p;


bool judge(int x,int y)
{
     if(x<0||x>=n||y<0||y>=m||a[x][y]=='.') return false;
     int i=x,j=y;

     if(a[i][j-1]=='.'&&a[i+1][j-1]=='.'&&a[i+1][j]=='.') return true;

     if(a[i-1][j]=='.'&&a[i-1][j+1]=='.'&&a[i][j+1]=='.') return true;

     if(a[i][j-1]=='.'&&a[i-1][j]=='.'&&a[i-1][j-1]=='.') return true;

     if(a[i][j+1]=='.'&&a[i+1][j]=='.'&&a[i+1][j+1]=='.') return true;

     return false;
}

void solve()
{
    queue<p>q;
    int i,j;
    fre(i,0,n)
     fre(j,0,m)
      if(judge(i,j))
        q.push(p(i,j));

    p cur;

    while(!q.empty())
    {
        cur=q.front();
        q.pop();
        int x=cur.first;
        int y =cur.second;
        if(!judge(x,y)) continue;
        a[x][y]='.' ;

        fre(i,-1,2)
          fre(j,-1,2)
          {
              if(judge(i+x,y+j))
                q.push(p(i+x,y+j));
          }
    }
    fre(i,0,n)
      pf("%s\n",a[i]);

}
int main()
{
    int i,j;
    while(~sff(n,m))
    {
        fre(i,0,n)
         ssf(a[i]);

        solve();
    }
  return 0;
}


扩散模型实战:从零开始训练手写数字生成模型 手写数字的数据集是绝大部分炼丹师的深度学习初恋,这篇博客以代码为主,手把手带读者搭建一个基于扩散模型的手写数字生成模型,非常适合刚接触扩散模型的初学者学习。 阅读详情

相关推荐

Ubuntu 22.04 “软件与更新”装了NVIDIA驱动,WiFi等设备不见了

在Win10装了Ubuntu22.04的双系统,台式机里面有NVIDIA 3080Ti的独立显卡,Ubuntu默认使用的nouveau驱动,需要更换成NVIDIA相应的驱动,在软件和更新里面一键安装了NVIDIA-driver-535-server之后,发现wifi、蓝牙等设备消失了。这个问题的根源据说跟这个nouveau驱动有关,希望linux社区可以解决这个问题。命令安装后 sudo reboot就可以重新看到WiFi以及蓝牙等设备图标了。然后用U盘拷贝到不能上网的Ubuntu22.04系统上,利用。

me_ysd的博客 5852

Codeforces Round #297 (Div. 2) D题. Arthur and Walls(BFS)

题目地址:Arthur and Walls 这题有一个脑洞,对于当前的点(i,j)并且此点为”*”来说,若存在包含它的2*2正方形中除了它自己外,另外三个点都是”.”,那么这个点就必须要变成”.”。由于去掉这个点之后会对周围的8个点造成影响,所以可以用BFS去搜。WA第12组的应该是只考虑了会影响到周围的4个点了。 代码如下:#include <iostream> #include <strin

scf0920 1451

Framelet Transform

需要定义 Framelet 的基函数。Framelet 基函数可以是通过组合不同的小波函数生成的。# 这里可以定义 Framelet 基函数,例如一些小波基函数的线性组合# 这是一个示例函数,具体实现需要根据具体的 Framelet 设计# 示例:正弦函数。

qq_33009429的博客 1210

D. Arthur and Walls(Codeforces Round #297 (Div. 2) 搜索(BFS))

D. Arthur and Walls time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Finally it is a day when Arthur has eno

叶孤心的专栏 626

CTFHUB------XSS反射型(WP)

文章目录前言XSS测试平台 前言 一开始我直接在上面写js脚本发现出错,最后发现只能通过下面的输入框来执行XSS测试,于是我们只能用XSS测试平台解决问题 XSS测试平台 注册一个XSS测试平台 这里随便填写 勾选默认模块就够了,点击下一步 这时会出现一个找个将代码复制 拼接到网站后缀name后面,点击send 这时平台会收到一个记录点开即可 得到flag ...

Y4tacker的博客 1万+

手把手教你用WKT文件在Petrel中创建自定义坐标系统(附CGCS2000转换模板)

本文详细介绍了如何在Petrel软件中利用WKT文件创建自定义坐标系统,并重点提供了CGCS2000坐标系的完整转换模板与实战步骤。通过解析坐标系统的三大支柱(大地坐标系、投影坐标系、基准转换)和WKT文件结构,指导用户从零开始构建适用于本土化项目的坐标系统,确保地质建模与空间数据处理的精度与一致性。

gpt4scribbler的博客 277

BFS Codeforces Round #297 (Div. 2) D. Arthur and Walls

题目传送门 1 /* 2 题意:问最少替换'*'为'.',使得'.'连通的都是矩形 3 BFS:搜索想法很奇妙,先把'.'的入队,然后对于每个'.'八个方向寻找 4 在2*2的方格里,若只有一个是'*',那么它一定要被替换掉 5 */ 6 #include <cstdio> 7 #include <iostre...

weixin_33712881的博客 130

告别环境配置烦恼:用Conda一键搞定GATK4、samtools、fastp等生信分析全家桶

本文介绍如何利用Conda快速搭建包含GATK4、samtools、fastp等工具的生物信息学分析环境,解决软件安装和版本冲突问题。通过详细的配置步骤和实战案例,帮助研究者十分钟内完成重测序分析全家桶的环境配置,显著提升上游分析效率。

weixin_30753873的博客 334

Codeforces Round #297 (Div. 2)D. Arthur and Walls 搜索bfs

题目链接:http://codeforces.com/contest/525/problem/D 题意给你一个n*m的田地,有一些*的地方是可以移除变成"."的,然后问你移除最少的"*",使的每一个"."的联通块都是矩形 题解:2*2 的矩形中,如果有一个 '*' 与三个 '.' ,那么这个 '*' 就一定要变成 ‘.' ,然后bfs 代码#include <bits/stdc++.h> using

yxg_123的博客 268

SAP-ABAP:SAP的BAPI_GOODSMVT_CREATE 深度解析

BAPI_GOODSMVT_CREATE 深度解析** **功能定位**:SAP 标准接口,支持 **11 种库存移动场景**(收货/发货/转储/生产投料等),是 MM 模块集成核心

baidu_35680696的博客 1823

WPF+MVVM案例实战(一)- 设备状态LED灯变化实现

采用WPF+MVVM框架实现,MVVM框架使用CommunityToolkit.Mvvm 依赖包,代码案例部署了三个LED灯,按照红黄绿三色后台自动刷新状态进行变化,根据后台数据不同,UI层显示不同颜色。

lingshuangcanxue 1381

Codeforces Round #297 (Div. 2) D. Arthur and Walls [ 思维 + bfs ]

传送门 D. Arthur and Walls time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Finally it is a day when Arthur has enough...

weixin_33991727的博客 146

简谈基于FPGA的千兆以太网设计

简谈基于FPGA的千兆以太网设计 今天给大侠带来简谈基于FPGA的千兆以太网设计,话不多说,上货。 今天我们来简单的聊一聊以太网,以太网在FPGA学习中属于比较高级的内容了,有些大侠肯定会感觉以太网学习起来非常不容易。其实,我可以告诉大家,前期学习的基础打扎实了,后期的学习也没那么难。总之就是说难没那么难,说容易也不是那么容易。那么,言归正传,下面让我们一起来聊一聊以太网的学习。 说起以太网,大家可能就会想到百兆以太网、千兆以太网以及万兆以太网等等。局域以太网从10M开始发展,经历几多的变迁,发展到现

3619

Codeforces Round #297 (Div. 2)D. Arthur and Walls 暴力搜索

Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 SecMemory Limit: 512 MBSubmit: xxx Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/D Description Finall...

weixin_30607659的博客 127

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

Codeforces Round #297 (Div. 2) D - Arthur and Walls

对图广搜,当当前点的一个脚中的通路大于2个,就把他全染成通路,新的通路加入队列。。 #include #include #include #include #include #include #include #include #include #include #include #include #include #define maxn 2005 #define m

yysys 467

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

HDU 5024 Wang Xifeng's Little Plot (bfs)

Problem Description 《Dream of the Red Chamber》(also 《The Story of the Stone》) is one of the Four Great Classical Novels of Chinese literature, and it is commonly regarded as the best one. This novel

左眼皮跳跳 1750

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

HDU 5025 Saving Tang Monk(bfs)

Problem Description 《Journey to the West》(also 《Monkey》) is one of the Four Great Classical Novels of Chinese literature. It was written by Wu Cheng'en during the Ming Dynasty. In this novel, Monkey

左眼皮跳跳 1312

POJ 3414 Pots (经典bfs )

poj 3414 两个壶倒水问题

左眼皮跳跳 1179

HDU 5012 Dice (bfs)

Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 98    Accepted Submission(s): 57 Problem Description There are 2 special dices on

左眼皮跳跳 1007

HDU 1885

Key Task Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1474    Accepted Submission(s): 605 Problem Description The Czech Technical Un

左眼皮跳跳 903

HDU 1429 胜利大逃亡(续)(bfs)

胜利大逃亡(续) Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6270    Accepted Submission(s): 2177 Problem Description Ignatius再次被魔王抓走了(搞不懂他

左眼皮跳跳 857

POJ 3026 bfs+最小生成树

poj 3026 bfs+最小生成树

左眼皮跳跳 823

HUD 1175 bfs广度搜索

Problem Description “连连看”相信很多人都玩过。没玩过也没关系,下面我给大家介绍一下游戏规则:在一个棋盘中,放了很多的棋子。如果某两个相同的棋子,可以通过一条线连起来(这条线不能经过其它棋子),而且线的转折次数不超过两次,那么这两个棋子就可以在棋盘上消去。不好意思,由于我以前没有玩过连连看,咨询了同学的意见,连线不能从外面绕过去的,但事实上这是错的。现在已经酿成大祸,就只能将

左眼皮跳跳 792
上一篇: Codeforces Round #297 (Div. 2) E Anya and Cubes
下一篇: HDU 5194 DZY Loves Balls(排列组合瞎搞 )
左眼皮跳跳~
博客等级 码龄13年 17粉丝 400原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值