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. hdoj 3555 BOMB(数位dp)

    //hdoj 3555 //2013-06-27-16.53 #include <stdio.h> #include <string.h> __int64 dp[21][3], ...

  2. Python基础总结之认识lambda函数、map函数、filter() 函数。第十二天开始(新手可相互督促)

    今天周日,白天在学习,晚上更新一些笔记,希望对大家能更好的理解.学习python~ lambda函数,也就是大家说的匿名函数.它没有具体的名称,也可以叫做一句话函数,我觉得也不过分,大家看下代码,来体 ...

  3. [译]Python中的异步IO:一个完整的演练

    原文:Async IO in Python: A Complete Walkthrough 原文作者: Brad Solomon 原文发布时间:2019年1月16日 翻译:Tacey Wong 翻译时 ...

  4. Android--SharedPreferences数据存储方案

            SharedPreferences是使用键值对的形式存储的,并且支持多种不同的数据类型,存的是String,取得值也是String.         使用SharedPreferenc ...

  5. Qt基于sqlite数据库的管理小软件

    闲来无事,写了一个基于sqlite的数据库管理小软件. 先上图 中心思想就是: 创建一个数据库 然后每一个分组对应一个数据表 然后遍历该数据表.将名字以treewidgetItem显示出来.添加删除实 ...

  6. spark shuffle读操作

    提出问题 1. shuffle过程的数据是如何传输过来的,是按文件来传输,还是只传输该reduce对应在文件中的那部分数据? 2. shuffle读过程是否有溢出操作?是如何处理的? 3. shuff ...

  7. nodeJs跨域设置(express,koa2,eggJs)

    原生跨域 var http=require('http'); var server = http.createServer(function (req,res) { res.setHeader('Ac ...

  8. 【原创实践】U大师启动安装windows XP

    1:使用U大师3.0版制作启动U盘,拷贝windows xp或者win7的原版安装iso(zh-hans_windows_xp_professional_with_service_pack_3_x86 ...

  9. 『开发技术』GPU训练加速原理(附KerasGPU训练技巧)

    0.深入理解GPU训练加速原理 我们都知道用GPU可以加速神经神经网络训练(相较于CPU),具体的速度对比可以参看我之前写的速度对比博文: [深度应用]·主流深度学习硬件速度对比(CPU,GPU,TP ...

  10. SQL获取客户端网卡电脑名称等信息

    Select SYSTEM_USER 当前用户名, USER_NAME() 当前所有者,db_Name() 当前数据库,@@SPID 当前进程号,(select top 1 FileName from ...