C. A Mist of Florescence
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

As the boat drifts down the river, a wood full of blossoms shows up on the riverfront.

"I've been here once," Mino exclaims with delight, "it's breathtakingly amazing."

"What is it like?"

"Look, Kanno, you've got your paintbrush, and I've got my words. Have a try, shall we?"

There are four kinds of flowers in the wood, Amaranths, Begonias, Centaureas and Dianthuses.

The wood can be represented by a rectangular grid of nn rows and mm columns. In each cell of the grid, there is exactly one type of flowers.

According to Mino, the numbers of connected components formed by each kind of flowers are aa, bb, cc and dd respectively. Two cells are considered in the same connected component if and only if a path exists between them that moves between cells sharing common edges and passes only through cells containing the same flowers.

You are to help Kanno depict such a grid of flowers, with nn and mm arbitrarily chosen under the constraints given below. It can be shown that at least one solution exists under the constraints of this problem.

Note that you can choose arbitrary nn and mm under the constraints below, they are not given in the input.

Input

The first and only line of input contains four space-separated integers aa, bb, cc and dd (1≤a,b,c,d≤1001≤a,b,c,d≤100) — the required number of connected components of Amaranths, Begonias, Centaureas and Dianthuses, respectively.

Output

In the first line, output two space-separated integers nn and mm (1≤n,m≤501≤n,m≤50) — the number of rows and the number of columns in the grid respectively.

Then output nn lines each consisting of mm consecutive English letters, representing one row of the grid. Each letter should be among 'A', 'B', 'C' and 'D', representing Amaranths, Begonias, Centaureas and Dianthuses, respectively.

In case there are multiple solutions, print any. You can output each letter in either case (upper or lower).

Examples
Input

Copy
  1. 5 3 2 1
Output

Copy
  1. 4 7
    DDDDDDD
    DABACAD
    DBABACD
    DDDDDDD
Input

Copy
  1. 50 50 1 1
Output

Copy
  1. 4 50
    CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
    ABABABABABABABABABABABABABABABABABABABABABABABABAB
    BABABABABABABABABABABABABABABABABABABABABABABABABA
    DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
Input

Copy
  1. 1 6 4 5
Output

Copy
  1. 7 7
    DDDDDDD
    DDDBDBD
    DDCDCDD
    DBDADBD
    DDCDCDD
    DBDBDDD
    DDDDDDD
Note

In the first example, each cell of Amaranths, Begonias and Centaureas forms a connected component, while all the Dianthuses form one.

嗯 就是一开始把50*50染成四种颜色,然后分别往里面塞不同颜色的块,这样就可以保证,在原有的块是1的情况下,一个一个的加,

当然要注意 每次行要+=2,列也要+=2,防止他们联通成一个,最后需要注意最后一列填充的时候,不要和他旁边的块联通;

一种方法是把D 填充到 A 的区域 这样对着填充,另外也可以不要从第一列开始往后+,从第二列,这样第25列就不会填充了(即每行最多12个)。

每种颜色最多有100个。  
所以每个块最多可以放数量12*12的其他颜色而不影响它自己的连通性。

  1. #include<iostream>
  2. #include<cstdio>
  3. #define For(i,a,b,num) for(int i=a; i<b&&num>0; i+=2)
  4. using namespace std;
  5.  
  6. char maps[][];
  7.  
  8. void paint(int sx,int sy,char word)
  9. {
  10. for(int i=sx; i<sx+; ++i){
  11. for(int j=sy; j<sy+; ++j){
  12. maps[i][j] = word;
  13. }
  14. }
  15. }
  16.  
  17. int main()
  18. {
  19. int a,b,c,d;
  20. scanf("%d%d%d%d",&a,&b,&c,&d);
  21. paint(,,'A');
  22. paint(,,'B');
  23. paint(,,'C');
  24. paint(,,'D');
  25. a--,b--,c--,d--;
  26. For(i,,,d){
  27. For(j,,,d){
  28. maps[i][j] = 'D';
  29. d--;
  30. }
  31. }
  32. For(i,,,c){
  33. For(j,,,c){
  34. maps[i][j] = 'C';
  35. c--;
  36. }
  37. }
  38. For(i,,,b){
  39. For(j,,,b){
  40. maps[i][j] = 'B';
  41. b--;
  42. }
  43. }
  44. For(i,,,a){
  45. For(j,,,a){
  46. maps[i][j] = 'A';
  47. a--;
  48. }
  49. }
  50. printf("50 50\n");
  51. for(int i=; i<; ++i){
  52. for(int j=; j<; ++j){
  53. printf("%c",*(maps[i]+j));
  54. }
  55. puts("");
  56. }
  57. }

C. A Mist of Florescence ----- Codeforces Round #487 (Div. 2)的更多相关文章

  1. Codeforces Round #487 (Div. 2) C - A Mist of Florescence

    C - A Mist of Florescence 把50*50的矩形拆成4块 #include<bits/stdc++.h> using namespace std; ],b[]; ][ ...

  2. Codeforces Round #487 (Div. 2) A Mist of Florescence (暴力构造)

    C. A Mist of Florescence time limit per test 1 second memory limit per test 256 megabytes input stan ...

  3. Codeforces Round #487 (Div. 2)

    A. A Blend of Springtime(暴力/模拟) 题目大意 给出$n$个花,每个点都有自己的颜色,问是否存在连续大于等于三个花颜色均不相同 sol 直接模拟判断即可 #include&l ...

  4. code forces Codeforces Round #487 (Div. 2) C

    C. A Mist of Florescence time limit per test 1 second memory limit per test 256 megabytes input stan ...

  5. Codeforces Round #487 (Div. 2) C. A Mist of Florescence 构造

    题意: 让你构造一个 n∗mn*mn∗m 矩阵,这个矩阵由 444 种字符填充构成,给定 444 个整数,即矩阵中每种字符构成的联通块个数,n,mn,mn,m 需要你自己定,但是不能超过505050. ...

  6. Codeforces Round #487 (Div. 2) 跌分有感

    又掉分了 这次的笑话多了. 首先,由于CF昨天的比赛太早了,忘记了有个ER,比赛开始半个小时才发现. 于是只能今天了. 嗯哈. 今天这场也算挺早的. 嗯嗯,首先打开A题. 草草看了一遍题意,以为不是自 ...

  7. Codeforces Round #487 (Div. 2) E. A Trance of Nightfall (矩阵优化)

    题意 有一个平面 , 给你 \(n\) 个点构成一个点集 \(S\) , 一开始可以选择一个平面上任意点 \(P\) . 存在一种操作 : 1 选择一条至少 通过 \(S\) 中任意两个点以及 \(P ...

  8. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. textarea中的回车识别问题

    <textarea name="" id="aa" cols="30" rows="10" wrap=" ...

  2. java基础题刷题中的知识点复习

    将变量转换为字符串方法:(String)待转对象..toString().String.valueOf(待转对象) 对字符串进行操作的方法,使用StringBuffer和StringBuilder定义 ...

  3. Hibrenate之事务的理解以及代码编写

    3 事务概念 事务(Transaction)是并发控制的单位,是用户定义的一个操作序列.这些操作要么都做,要么都不做,是一个不可分割的工作单位.通过事务,SQL Server能将逻辑相关的一组操作绑定 ...

  4. UINavigationController 、navigationBar 、 UINavigationItem、UIBarButtonItem之间的关系

  5. LeetCode(92):反转链表 II

    Medium! 题目描述: 反转从位置 m 到 n 的链表.请使用一趟扫描完成反转. 说明:1 ≤ m ≤ n ≤ 链表长度. 示例: 输入: 1->2->3->4->5-&g ...

  6. hdu4738 求割边

    细节题:1.如果图不连通,则输出0 2.如果图没有桥,本身是双联通图,则输出-1 3.如果最小的桥权值为0,任然要输出1 #include<bits/stdc++.h> using nam ...

  7. Centos7搭建dhcp服务器

    实验拓扑: 实验步骤如下: 1.挂载本地镜像,并安装dhcp组件. 2.更改配置文件,并重启服务. . 3.配置dhcp地址池范围 4.配置防火墙 结果:在客户端上,重启网卡,后查看ip

  8. K/3 Cloud Web API接口说明文

    K/3 Cloud Web API接口说明文 目的 三方集成,提供第三方系统与Cloud集成调用接口. 技术实现 HTTP + Json 提供标准接口 编号 名称 说明 1 Kingdee.BOS.W ...

  9. EF批量插入数据(Z.EntityFramework.Extensions)

    EF用原生的插入数据方法DbSet.ADD()和 DbSet.AddRange()都很慢.所以要做大型的批量插入只能另选它法. 1.Nugget 2.代码 using EF6._0Test.EF; u ...

  10. [转] createObjectURL方法 实现本地图片预览

    ie6 可以直接显示本本地路径的图片 如: <img src="file://c:/3.jpg" />  ~~~网上都说ie7就不支持这种文件系统路径的url,但测试 ...