AtCoder Regular Contest 093 D - Grid Components
#include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<algorithm> #include<iostream> #include<queue> #include<map> #include<cmath> #include<set> #include<stack> #define ll long long #define pb push_back #define max(x,y) ((x)>(y)?(x):(y)) #define min(x,y) ((x)>(y)?(y):(x)) #define cls(name,x) memset(name,x,sizeof(name)) #define fs first #define sc second #define mp make_pair #define L(x) (1<<x) #define next Next #define index Index using namespace std; const int inf=1e9+10; const ll llinf=1e17+10; const int maxn=2e5+10; const int maxm=1e6+10; const int maxk=100; const int mod=1e9+7; int A,B; int num[maxn]; char str[maxk][maxk]; char s1[10][10]={"###.","#.#.","###.","...."};//1#1. char s2[10][10]={"....","..#.","....","...."};//1# char s3[10][10]={"...#",".#.#","...#","####"};//1#1. char s4[10][10]={"####","##.#","####","####"};//1. int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); while (~scanf("%d %d",&A,&B)) { if(B>=A-1) { fill(str[0],str[0]+maxk*maxk,'.'); A--; for(int i=0;i<maxk;i+=4) for(int j=0;j<maxk;j+=4) { if(A>=1) { for(int k1=0;k1<4;k1++) for(int k2=0;k2<4;k2++) str[i+k1][j+k2]=s1[k1][k2]; A--; B--; } else if(B>=1) { for(int k1=0;k1<4;k1++) for(int k2=0;k2<4;k2++) str[i+k1][j+k2]=s2[k1][k2]; B--; } } } else if(A>=B-1) { fill(str[0],str[0]+maxk*maxk,'#'); B--; for(int i=0;i<maxk;i+=4) for(int j=0;j<maxk;j+=4) { if(B>=1) { for(int k1=0;k1<4;k1++) for(int k2=0;k2<4;k2++) str[i+k1][j+k2]=s3[k1][k2]; A--; B--; } else if(A>=1) { for(int k1=0;k1<4;k1++) for(int k2=0;k2<4;k2++) str[i+k1][j+k2]=s4[k1][k2]; A--; } } } printf("%d %d\n",maxk,maxk); for(int i=0;i<maxk;i++) for(int j=0;j<maxk;j++) printf("%c%s",str[i][j],j==maxk-1?"\n":""); } return 0; }