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
5 3 2 1
Output

Copy
4 7
DDDDDDD
DABACAD
DBABACD
DDDDDDD
Input

Copy
50 50 1 1
Output

Copy
4 50
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
ABABABABABABABABABABABABABABABABABABABABABABABABAB
BABABABABABABABABABABABABABABABABABABABABABABABABA
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
Input

Copy
1 6 4 5
Output

Copy
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的其他颜色而不影响它自己的连通性。

 #include<iostream>
#include<cstdio>
#define For(i,a,b,num) for(int i=a; i<b&&num>0; i+=2)
using namespace std; char maps[][]; void paint(int sx,int sy,char word)
{
for(int i=sx; i<sx+; ++i){
for(int j=sy; j<sy+; ++j){
maps[i][j] = word;
}
}
} int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
paint(,,'A');
paint(,,'B');
paint(,,'C');
paint(,,'D');
a--,b--,c--,d--;
For(i,,,d){
For(j,,,d){
maps[i][j] = 'D';
d--;
}
}
For(i,,,c){
For(j,,,c){
maps[i][j] = 'C';
c--;
}
}
For(i,,,b){
For(j,,,b){
maps[i][j] = 'B';
b--;
}
}
For(i,,,a){
For(j,,,a){
maps[i][j] = 'A';
a--;
}
}
printf("50 50\n");
for(int i=; i<; ++i){
for(int j=; j<; ++j){
printf("%c",*(maps[i]+j));
}
puts("");
}
}

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. Vue.js结合vue-router和webpack编写单页路由项目

    一.前提 1. 安装了node.js. 2. 安装了npm. 3. 检查是否安装成功: 打开cmd,输入node,没有报“node不是内部或外部命令”表示安装成功node.js. 打开cmd,输入np ...

  2. 【python】多进程与mongo

    参考:http://api.mongodb.com/python/current/faq.html#using-pymongo-with-multiprocessing 如果使用了多进程,则必须在子进 ...

  3. trade war

    问题 C: trade war 时间限制: 1 Sec  内存限制: 128 MB 题目描述 2018年的春天,特朗普这个不靠谱的的家伙悍然向中国发起了贸易战,贸易战是一场没有赢家的战争,美国向中国商 ...

  4. Jmeter 谷歌插件工具blazemeter录制脚本

    1.下载谷歌浏览器插件工具:blazemeter. 2.在谷歌浏览器中拖放安装扩展工具:blazemeter. 粘贴的图像828x219 13.5 KB 3.测试网站利用这个工具录制jmter脚本. ...

  5. 滴水穿石-07Java开发中常见的错误

    1:使用工具Eclipse 1.1 "语法错误" 仅当源级别为 1.5 时已参数化的类型才可用 设置eclipse,窗口—>java—>编译器—>JDK一致性调到 ...

  6. .NetCore 下开发独立的(RPL)含有界面的组件包 (四)授权过滤

    .NetCore 下开发独立的(RPL)含有界面的组件包 (一)准备工作 .NetCore 下开发独立的(RPL)含有界面的组件包 (二)扩展中间件及服 务 .NetCore 下开发独立的(RPL)含 ...

  7. CentOS6.9安装Filebeat监控Nginx的访问日志发送到Kafka

    一.下载地址: 官方:https://www.elastic.co/cn/downloads/beats/filebeat 百度云盘:https://pan.baidu.com/s/1dvhqb0 二 ...

  8. Cisco交换机基础命令 + Win Server08 R2 多网卡配置链路聚合

    最近捣鼓服务器链路集合需要配置交换机… 以前没弄过交换机,现学现卖… 一般交换机是支持telnet的,配置好ip可以直接telnet,当然如果没配的话就要用串口了,串口要选择Serial… 还好我们万 ...

  9. CDOJ 1960 构造哈密顿路径

    题意: 给定n个点的有向完全图,希望通过其中n-1条边将n个点串起来(2<=n<=1000) 欧拉路径:经过所有边且只经过一次 哈密顿路径:经过所有点且只经过一次 思路: 本题条件特殊,有 ...

  10. 转:ubuntu-E:Encountered a section with no Package: header的解决办法

    http://blog.csdn.net/hs794502825/article/details/7835902 blog.csdn.net/lixiang0522/article/details/7 ...