【题解】AT2043 AND Grid

我们考虑直接构造两个互补的图切分别联通的图,然后原图有的大家都有就构造完成了。

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<bitset>
#include<vector>
#include<map>
#include<ctime>
#include<cstdlib>
#include<set>
#include<bitset>
#include<stack>
#include<list>
#include<cmath>
using namespace std;
#define RP(t,a,b) for(register int (t)=(a),edd_=(b);t<=edd_;++t)
#define DRP(t,a,b) for(register int (t)=(a),edd_=(b);t>=edd_;--t)
#define ERP(t,a) for(int t=head[a];t;t=e[t].nx)
#define Max(a,b) ((a)<(b)?(b):(a))
#define Min(a,b) ((a)<(b)?(a):(b))
#define TMP template<class ccf>
#define lef L,R,l,mid,pos<<1
#define rgt L,R,mid+1,r,pos<<1|1
#define midd register int mid=(l+r)>>1
#define chek if(R<l||r<L)return
#define all 1,n,1
#define pushup(x) seg[(x)]=seg[(x)<<1]+seg[(x)<<1|1]
typedef long long ll;
TMP inline ccf qr(ccf k){
char c=getchar();
ccf x=0;
int q=1;
while(c<48||c>57)
q=c==45?-1:q,c=getchar();
while(c>=48&&c<=57)
x=x*10+c-48,c=getchar();
if(q==-1)
x=-x;
return x;
}
const int maxn=505;
bool g1[maxn][maxn];
int m,n; inline bool qrqr(){
char c=getchar();
while(c!='.'&&c!='#')
c=getchar();
return c=='#';
} int main(){
n=qr(1);
m=qr(1);
RP(t,1,n)
RP(i,1,m)
g1[t][i]=qrqr(); RP(t,1,n){
RP(i,1,m)
if(g1[t][i]||((t&1)&&i!=m)||i==1)
cout<<'#';
else
cout<<'.';
cout<<endl;
}putchar('\n');
RP(t,1,n){
RP(i,1,m)
if(g1[t][i]||((!(t&1))&&i!=1)||i==m)
cout<<'#';
else
cout<<'.';
cout<<endl;
}
return 0;
}

【题解】AT2043 AND Grid的更多相关文章

  1. AT2043 AND Grid 构造

    正解:构造 解题报告: 传送门传送门! 这题psj讲了俩做法,一个是最常见的解法,还一种还不知道484对的QAQ 然后先把psj讲的不知正确性的做法港下QwQ 大概就是说,第一个图,先把底给染完 然后 ...

  2. 题解报告:poj 2185 Milking Grid(二维kmp)

    Description Every morning when they are milked, the Farmer John's cows form a rectangular grid that ...

  3. ZOJ - 3781 Paint the Grid Reloaded 题解

    题目大意: 给一个n*m的X O构成的格子,对一个点操作可以使与它相连通的所有一样颜色的格子翻转颜色(X—>O或O—>X),问给定的矩阵最少操作多少次可以全部变成一样的颜色. 思路: 1. ...

  4. POJ2185 Milking Grid 题解 KMP算法

    题目链接:http://poj.org/problem?id=2185 题目大意:求一个二维的字符串矩阵的最小覆盖子矩阵,即这个最小覆盖子矩阵在二维空间上不断翻倍后能覆盖原始矩阵. 题目分析:next ...

  5. Codeforces Round #597 (Div. 2) D. Shichikuji and Power Grid 题解 最小生成树

    题目链接:https://codeforces.com/contest/1245/problem/D 题目大意: 平面上有n座城市,第i座城市的坐标是 \(x[i], y[i]\) , 你现在要给n城 ...

  6. AT2043 [AGC004C] AND Grid

    首先可以发现一个很简单的想法,因为最外层是一定不会有 \(\#\) 的,所以可以考虑让第一个网格图将每个连通块的最外层包起来,第二个网格图将就选择这个包内部的所有点即可. 但你发现这个想法是很难实现的 ...

  7. CF1703E Mirror Grid 题解

    给定一个矩阵,判断最少将多少个格反转后使得旋转零度,九十度,一百八十度,二百七十度相等. 枚举矩阵每个位置是 \(0\) 还是 \(1\),若已经判断过则跳过,全统 \(1\) 和全统 \(0\) 取 ...

  8. NBUT1541 Rainwater 题解

    http://cdn.ac.nbutoj.com/Problem/view.xhtml?id=1541 When rain, nocLyt discovered a magical phenomeno ...

  9. POJ 2185 Milking Grid KMP(矩阵循环节)

                                                            Milking Grid Time Limit: 3000MS   Memory Lim ...

随机推荐

  1. 手把手教你构建 C 语言编译器

    http://lotabout.me/2015/write-a-C-interpreter-1/

  2. 3 Suggested Oracle Certifications For Oracle Form's Developers

    The following are the most suggested Oracle Certifications for Oracle Application Developers in Form ...

  3. Django 创建APP - 简单路由系统案例

    架构图: setting.py: INSTALLED_APPS = [ ... 'bootstrap', ] myapp -> myapp -> urls.py from django.c ...

  4. SFTP &amp; FTP Upload

    简述 >> FTP: 1. Install FTP service on Linux(Red Hat) as root user    [root]# yum install ftp 2. ...

  5. 微信开发token验证失败

    遇到token验证时: 1.首先检验是否是80端口或443端口,能否接收到微信的响应信息,如果使用域名,域名要备注,否则接收不到响应信息: 2.其次判断是否能正常echo $echoStr,之前不能有 ...

  6. ElasticSearch的备份迁移方案

    使用插件repository-hdfs插件进行测试 下载地址: https://oss.sonatype.org/content/repositories/snapshots/org/elastics ...

  7. java基础篇4之注解

    1 注解的应用(jdk1.5的新特性) 一个注解相当于一个特殊的类 例子: @SuppressWarning("deprecation") @Deprecated @Overrid ...

  8. Codis的了解和操作

    1.Codis的基本架构 2.Codis各组件 Codis-server:就是redis服务,可以使用codis修改的reids和原生的redis Codis-proxy:客户端连接的代理服务,客户端 ...

  9. 转: maven打可执行的jar包以及classpath设置

    from:  http://drizzlewalk.blog.51cto.com/2203401/416508

  10. 获取input光标的x和y轴

    http://blog.csdn.net/kingwolfofsky/article/details/6586029 index.html <!DOCTYPE html> <html ...