AtCoder Grand Contest 004 C - AND Grid(思路题)
题意:
给你一个n*m的矩阵,矩阵中有.和#,#表示两图重合的部分,边缘没有#
然后要你构造两个n*m的图,要求#是连通的,然后合并之后重合的部分就是原图中的#
思路:
又是一到思路题
当时被B题智商压制没读这道题
就是构造一个这种图
然后重合部分两个图都填为#就可以了
/* *********************************************** Author :devil ************************************************ */ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <cmath> #include <stdlib.h> #define inf 0x3f3f3f3f #define LL long long #define rep(i,a,b) for(int i=a;i<=b;i++) #define dec(i,a,b) for(int i=a;i>=b;i--) #define ou(a) printf("%d\n",a) #define pb push_back #define mkp make_pair template<class T>inline void rd(T &x){char c=getchar();x=0;while(!isdigit(c))c=getchar();while(isdigit(c)){x=x*10+c-'0';c=getchar();}} #define IN freopen("in.txt","r",stdin); #define OUT freopen("out.txt","w",stdout); using namespace std; const int mod=1e9+7; const int N=510; char s1[N][N],s2[N][N],s[N][N]; int main() { int n,m; rd(n),rd(m); rep(i,1,n) { s1[i][1]='#',s1[i][m]='.'; s2[i][m]='#',s2[i][1]='.'; rep(j,2,m-1) (i%2)?(s1[i][j]='#',s2[i][j]='.'):(s2[i][j]='#',s1[i][j]='.'); } rep(i,1,n) scanf("%s",s[i]+1); rep(i,2,n-1) rep(j,2,m-1) if(s[i][j]=='#') s1[i][j]=s2[i][j]='#'; rep(i,1,n) { rep(j,1,m) printf("%c",s1[i][j]); puts(""); } puts(""); rep(i,1,n) { rep(j,1,m) printf("%c",s2[i][j]); puts(""); } return 0; }