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.

题意: 给你A,B,C,D连通量的数目(连通量指上或下或左或右有连接),要你给出一个矩阵(给出的矩阵长宽小于等于50)满足这样的要求

引入别人博客的一张图

图中说明了一切  将你的矩阵四分,分别填充B,A,D,C,然后在这四个矩阵中按要求填充

#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(a) cout << #a << " " << a << endl
using namespace std;
const int maxn = 1e2 + ;
const int mod = 1e9 + ;
typedef long long ll;
char mapn[maxn][maxn];
void myfill( ll xs, ll ys, ll xe, ll ye, char c ) {
for( ll i = xs; i <= xe; i ++ ) {
for( ll j = ys; j <= ye; j ++ ) {
mapn[i][j] = c;
}
}
}
int main(){
std::ios::sync_with_stdio(false);
ll a, b, c, d;
while( cin >> a >> b >> c >> d ) {
a --, b --, c --, d --;
myfill( , , , , 'B' );
myfill( , , , , 'A' );
myfill( , , , , 'D' );
myfill( , , , , 'C' );
for( ll i = ; i <= ; i ++ ) {
for( ll j = ; j <= ; j ++ ) {
if( i % && j % && a ) {
mapn[i][j] = 'A';
a --;
}
}
}
for( ll i = ; i <= ; i ++ ) {
for( ll j = ; j <= ; j ++ ) {
if( i % == && j % == && b ) {
mapn[i][j] = 'B';
b --;
}
}
}
for( ll i = ; i <= ; i ++ ) {
for( ll j = ; j <= ; j ++ ) {
if( i % && j % && c ) {
mapn[i][j] = 'C';
c --;
}
}
}
for( ll i = ; i <= ; i ++ ) {
for( ll j = ; j <= ; j ++ ) {
if( i % == && j % == && d ) {
mapn[i][j] = 'D';
d --;
}
}
}
cout << "50 50" << endl;
for( ll i = ; i <= ; i ++ ) {
cout << mapn[i] << endl;
}
}
return ;
}

CF989C A Mist of Florescence 构造 思维好题 第八题的更多相关文章

  1. CF989C A Mist of Florescence 构造

    正解:构造 解题报告: 先放传送门yep! 然后构造题我就都直接港正解了QwQ没什么可扯的QwQ 这题的话,首先这么想吼 如果我现在构造的是个4*4的 举个栗子 AABB ACBB AADB DBCA ...

  2. CF989C A Mist of Florescence (构造)

    CF989C A Mist of Florescence solution: 作为一道构造题,这题确实十分符合构造的一些通性----(我们需要找到一些规律,然后无脑循环).个人认为这题规律很巧妙也很典 ...

  3. 【题解】CF989C A Mist of Florescence

    [题解]CF989C A Mist of Florescence 题目大意: 让你构造一个\(n∗m\)矩阵,这个矩阵由4种字符填充构成,给定4个整数,即矩阵中每种字符构成的四联通块个数,\(n,m\ ...

  4. CF989C A Mist of Florescence

    思路: 有趣的构造题. 实现: #include <bits/stdc++.h> using namespace std; ][]; void fillin(int x, int y, c ...

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

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

  6. CF989C A Mist of Florescence 题解

    因为 \(1 \leq a,b,c,d \leq 100\) 所以每一个颜色都有属于自己的联通块. 考虑 \(a = b=c=d=1\) 的情况. AAAAAAAAAAAAAAAAAAAAAAAAAA ...

  7. CF思维联系– Codeforces-989C C. A Mist of Florescence

    ACM思维题训练集合 C. A Mist of Florescence time limit per test 1 second memory limit per test 256 megabytes ...

  8. 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 ...

  9. Codeforces A Mist of Florescence

    A Mist of Florescence 题目大意: 事先告诉你每种颜色分别有几个联通块,构造一个不超过 \(50*50\) 的矩形.用 \(A,B,C,D\) 四种颜色来对矩形进行涂色使它满足要求 ...

随机推荐

  1. Spring Boot简单环境搭建

    #### 一.创建一个简单的Maven项目 使用`Maven`,通过导入`Spring Boot`的`starter`模块,可以将许多程序依赖的包自动导入到工程中.使用`Maven`的`parent ...

  2. 用多个分隔符切分字符串---re.split()

    问题/需求: 需要将字符串切分,但是分隔符在整个字符串中并不一致 (即:需要用多个分隔符切分字符串) str.split()方法不可行: 只支持单一分隔符,不支持正则及多个切割符号,不感知空格的数量 ...

  3. 学好C/C++编程,走遍天下都不怕

    C++这门语言从诞生到今天已经经历了将近30个年头.不可否认,它的学习难度都比其它语言较高.而它的学习难度,主要来自于它的复杂性.现在C++的使用范围比以前已经少了很多,java.C#.python等 ...

  4. linux CPU100%异常排查

    1.top查找出占CPU比例最高的进程(5881): 2.查看该进程正在执行的线程: top -H -p  5881 3.将线程转换成16进制 printf ‘%x\n’ 5950 4.查看异常线程执 ...

  5. 理解MySQL(一)--MySQL介绍

    一.Mysql逻辑架构: 1. 第一层:服务器层的服务,连接\线程处理. 2. 第二层:查询执行引擎,MySQL的核心服务功能,包括查询解析.分析.优化和缓存,所有跨存储引擎的功能都在这一层实现. 3 ...

  6. 基于python语言使用余弦相似性算法进行文本相似度分析

    编写此脚本的目的: 本人从事软件测试工作,近两年发现项目成员总会提出一些内容相似的问题,导致开发抱怨.一开始想搜索一下是否有此类工具能支持查重的工作,但并没找到,因此写了这个工具.通过从纸上谈兵到着手 ...

  7. 解决oh-my-zsh中git分支显示乱码问题

    oh-my-zsh显示github分支时,如果当前文件夹不是git仓库,它就会显示乱码.倒腾了好几个小时终于弄清楚是oh-my-zsh中函数”git_prompt_info“的锅,然后又花了半个多小时 ...

  8. 深度学习模型训练技巧 Tips for Deep Learning

    一.深度学习建模与调试流程 先看训练集上的结果怎么样(有些机器学习模型没必要这么做,比如决策树.KNN.Adaboost 啥的,理论上在训练集上一定能做到完全正确,没啥好检查的) Deep Learn ...

  9. word2vec原理分析

    本文摘录整编了一些理论介绍,推导了word2vec中的数学原理,理论部分大量参考<word2vec中的数学原理详解>. 背景 语言模型 在统计自然语言处理中,语言模型指的是计算一个句子的概 ...

  10. Gin + Vue全栈开发实战(二)

    尝试地写了第一篇自己学习Go Web框架的感受和入门的文章,发现反响还不错,大家也提出了很多的问题来一起交流.近期也渐渐地出现了很多有关go语言开发的相关文章,包括有在蚂蚁金服的大牛的分享,我也一直有 ...