这题说的是给了一个矩阵,必须让.连接起来的图形变成矩形,2000*2000的矩形,那么我们就可以知道了,只要是存在一个有点的区域应该尽量将他削为矩形,那么将这个图形进行缩放,最后我们知道只要存在一个2*2 的矩形中有1个是*就必须将这个*号去掉。 采用bfs去做

 #include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <queue>
using namespace std;
const int maxn = ;
char ma[maxn][maxn];
int num[maxn][maxn];
bool inq[maxn*maxn];
int tx[]={ ,-, -, -, , , , ,};
int ty[]={ -,-, , , , , ,- , -};
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)==){
queue<int>Q;
for(int i=; i<n; i++){
scanf("%s",ma[i]);
for(int j=; j<m; j++)
if(ma[i][j]=='.') {
Q.push(i*m+j);
}
}
while(!Q.empty()){
int id = Q.front(); Q.pop();
int xx = id/m, yy=id%m;
for(int i =; i<; i+=){
int sum=,loc=-;
for(int j=i; j<i+; j++){
int dx = xx + tx[j];
int dy = yy + ty[j];
if(dx<||dx>=n ||dy>=m||dy<)
sum=;
if(ma[dx][dy]=='*')
sum++,loc=dx*m+dy;
if(sum>)break;
}
if(sum==){
ma[loc/m][loc%m]='.'; Q.push(loc);
}
}
}
for(int i=; i<n; i++)
printf("%s\n",ma[i]);
}
return ;
}

codeforces D - Arthur and Walls的更多相关文章

  1. CodeForces 525D Arthur and Walls

    广搜.看了官方题解才会的..... 定义2*2的小矩阵,有三个是点,一个是星,这样的小矩阵被称为元素块. 首先把所有元素块压入队列,每次取出对头,检查是否还是元素块,如果是 那么将那个*改为点,否则跳 ...

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

    Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec  Memory Limit: 512 MBSubmit: xxx ...

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

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

  4. 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 stan ...

  5. Codeforces Round #297 (Div. 2) 525D Arthur and Walls(dfs)

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

  6. Arthur and Walls CodeForces - 525D (bfs)

    大意: 给定格点图, 每个'.'的连通块会扩散为矩形, 求最后图案. 一开始想得是直接并查集合并然后差分, 但实际上是不对的, 这个数据就可以hack掉. 3 3 **. .** ... 正解是bfs ...

  7. [BFS,大水题] Codeforces 198B Jumping on Walls

    题目:http://codeforces.com/problemset/problem/198/B Jumping on Walls time limit per test 2 seconds mem ...

  8. Codeforces 508E Arthur and Brackets 区间dp

    Arthur and Brackets 区间dp, dp[ i ][ j ]表示第 i 个括号到第 j 个括号之间的所有括号能不能形成一个合法方案. 然后dp就完事了. #include<bit ...

  9. Codeforces 101628A - Arthur's Language

    101628A - Arthur's Language 思路:dp,状态转移见代码. 代码: #include<bits/stdc++.h> using namespace std; #d ...

随机推荐

  1. windows桌面通知区域不显示音量图标的解决方法

    在windows系统桌面通知区域一般都是显示的输入法.电源.网络.音量及托盘的应用程序等内容 通知区域图标显示与否与控制面板的通知区域图标的设置有关,我们有时会遇到通知区域不显示个别图标的情况,如不显 ...

  2. 【CF896E】Welcome home, Chtholly 暴力+分块+链表

    [CF896E]Welcome home, Chtholly 题意:一个长度为n的序列ai,让你支持两种操作: 1.l r x:将[l,r]中ai>x的ai都减去x.2.l r x:询问[l,r ...

  3. Exception in thread "main" java.lang.StackOverflowError

    总结:1.创建对象时,在父类构造方法new子类对象,这样会造成循环调用构造方法

  4. ELKStack之消息队列

    redis消息队列 安装redis yum -y install redis 修改配置文件 修改ip 后台运行 启动 systemctl start redis 查看 lsof -i:6379 连接 ...

  5. ibatis sqlmap配置问题 “Check the IBatisNet.DataAccess.DaoSessionHandlers.SqlMapDaoSessionHandler.”

    - The error occurred while configure DaoSessionHandler.- The error occurred in <property name=&qu ...

  6. ElasticSearch报 EsThreadPoolExecutor[search, queue capacity = 1000, org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@c0efba

    ElasticSearch报以下错误的解决办法: "type": "es_rejected_execution_exception", "reason ...

  7. vue - 组件的创建

    组件的创建 vue的核心基础就是组件的使用,玩好了组件才能将前面学的基础更好的运用起来.组件的使用更使我们的项目解耦合.更加符合vue的设计思想MVVM. 那接下来就跟我看一下如何在一个Vue实例中使 ...

  8. Loadrunner之https协议录制回放报错如何解决?(九)

    一.录制中遇到报错27778的问题(如下图1),即关于录制的链接为https开头的问题,分两个步骤解决,如下: 图1 https访问报错解决步骤如下: 1.修改Vuser-->Run-time ...

  9. 【Python】小练习

    1.python爬虫 (1)抓取一个新闻网上含有某一关键字的新闻,http://internasional.kompas.com/就是这个网站上面所有内容含有THAAD这个关键词的新闻 (2)爬取大众 ...

  10. 显示界面的流畅性FHHFPSIndicator

    github地址https://github.com/jvjishou/FHHFPSIndicator 1.使用cocoapods  pod 'FHHFPSIndicator' 使用方法: 然后在Ap ...