题解 [CF525D] Arthur and Walls】的更多相关文章

题面 解析 首先考虑将一个\('*'\)变成\('.'\)后会形成什么, 显然至少是一个\(2\times 2\)的矩形. 因为\(1\times 1\)和\(1\times 2\)的改了没用啊, 而我们考虑什么时候应该把\('*'\)改掉, 对于一个矩形,它可以看成若干个可能重叠的\(2\times 2\)的矩形, 而在一个\(2\times 2\)的矩形中, 如果有三个是\('.'\),一个是\('*'\)的话,这个\('*'\)就要改掉, 要不然是不可能拼成矩形的. (感性理解下吧...)…
Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec  Memory Limit: 512 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/D Description Finally it is a day when Arthur has enough money for buying an apartment. H…
传送门 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 cente…
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…
题目传送门 /* 题意:问最少替换'*'为'.',使得'.'连通的都是矩形 BFS:搜索想法很奇妙,先把'.'的入队,然后对于每个'.'八个方向寻找 在2*2的方格里,若只有一个是'*',那么它一定要被替换掉 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <queue> using namespace std; ;…
题目链接 戳我 \(Solution\) 如果一个#要更改,那么一个四个格子的正方形只有他一个是#,bfs弄一下就好了 \(Code\) #include<bits/stdc++.h> using namespace std; const int inf=1e9,mod=1e9+7; typedef long long ll; int read() { int x=0,f=1; char c=getchar(); while(c<'0'||c>'9') f=(c=='-')?-1:…
广搜.看了官方题解才会的..... 定义2*2的小矩阵,有三个是点,一个是星,这样的小矩阵被称为元素块. 首先把所有元素块压入队列,每次取出对头,检查是否还是元素块,如果是 那么将那个*改为点,否则跳过 改完之后,检查周围8个点是否是元素块,如果有新产生的元素块,那么压入队列. 这样操作完之后就是答案. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include&l…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 考虑,为什么一个连通块里面的空格没有变成一个矩形? 如果不是形成矩形的话. 肯定是因为某个2x2的单张方形里面. 只有一个角是墙.其他角都是空的正方形. 举一些例子. ...* *... 可以看到这个连通块不是长方形. 就是因为有 .. *. 和 .* .. 如果我们把这两个角上的墙给删掉的话. 显然就能得到一个矩形了. 根据这个作为启发. 我们可以将整张图里面所有的2x2的正方形里面的"角"都给删掉. 这样的话,就能…
判断2*2的正方形,是不是3个"."1个"*"然后暴力bfs就好.(这种处理也是挺神奇的2333%%题解) #include<bits/stdc++.h> #define INF 0x7fffffff #define LL long long #define N 100005 #define pill pair<int ,int > using namespace std; inline int ra() { ,f=; char ch=get…
大意: 给定格点图, 每个'.'的连通块会扩散为矩形, 求最后图案. 一开始想得是直接并查集合并然后差分, 但实际上是不对的, 这个数据就可以hack掉. 3 3 **. .** ... 正解是bfs, 一个点被扩散当且仅当它所在的某个2*2块中只有它为'*'. #include <iostream> #include <iostream> #include <algorithm> #include <cstdio> #include <math.h&…