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
5 3 2 1
output
4 7
DDDDDDD
DABACAD
DBABACD
DDDDDDD
input
50 50 1 1
output
4 50
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
ABABABABABABABABABABABABABABABABABABABABABABABABAB
BABABABABABABABABABABABABABABABABABABABABABABABABA
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
input
1 6 4 5
output
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.

你们看代码吧 !这题简直超级无脑,超级暴力,然而我还写不出 !!!我太菜了我菜爆了

 #include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
typedef long long LL;
const int maxn = 3e5 + ; char tu[][];
int num[];
int dx[] = {, , , -};
int dy[] = {, -, , };
int check(int i, int j ) {
if (i < || i >= || j < || j >= ) return ;
return ;
}
int check1(int i, int j, char cnt ) {
for (int k = ; k < ; k++) {
int nx = i + dx[k];
int ny = j + dy[k];
// printf("%c %c\n",tu[nx][ny],cnt);
if (check(nx, ny)) {
if (tu[nx][ny] == cnt) return ;
}
}
return ;
}
int main() {
char s[] = "ABCD";
scanf("%d%d%d%d", &num[], &num[], &num[], &num[]);
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) {
if (i < && j < ) tu[i][j] = 'A';
if (i < && j >= ) tu[i][j] = 'B';
if (i >= && j < ) tu[i][j] = 'C';
if (i >= && j >= ) tu[i][j] = 'D';
}
}
if (num[] - ) {
int cnt = ;
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) {
if (i >= && j >= ) {
int sum = ;
for (int k = ; k < ; k++) {
if (tu[i - ][k] == 'A') sum++;
}
if (sum > ) break;
if (tu[i][j] == 'D' && check1(i, j, s[] ) ) {
tu[i][j] = 'A';
cnt++;
}
if (cnt == num[]) break;
}
}
if (cnt == num[]) break;
}
}
if (num[] - ) {
int cnt = ;
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) {
if (i >= && j < ) {
int sum = ;
for (int k = ; k < ; k++) {
if (tu[i - ][k] == 'B') sum++;
}
if (sum > ) break;
if (tu[i][j] == 'C' && check1(i, j, s[]) ) {
tu[i][j] = 'B';
cnt++;
}
}
if (cnt == num[]) break;
}
if (cnt == num[]) break;
}
}
if (num[] - ) {
int cnt = ;
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) {
if (i < && j >= ) {
int sum = ;
for (int k = ; k < ; k++) {
if (tu[i - ][k] == 'C') sum++;
}
if (sum > ) break;
if (tu[i][j] == 'B' && check1(i, j, s[]) ) {
tu[i][j] = 'C';
cnt++;
}
}
if (cnt == num[]) break;
}
if (cnt == num[]) break;
}
}
if (num[] - ) {
int cnt = ;
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) {
if (i < && j < ) {
int sum = ;
for (int k = ; k < ; k++) {
if (tu[i - ][k] == 'D') sum++;
}
if (sum > ) break;
if (tu[i][j] == 'A' && check1(i, j, s[]) ) {
tu[i][j] = 'D';
cnt++;
}
}
if (cnt == num[]) break;
}
if (cnt == num[]) break;
}
}
printf("50 50\n");
for (int i = ; i < ; i++)
printf("%s\n", tu[i]);
return ;
}

View

Codeforces Round #487 (Div. 2) A Mist of Florescence (暴力构造)的更多相关文章

  1. Codeforces Round #297 (Div. 2)D. Arthur and Walls 暴力搜索

    Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec  Memory Limit: 512 MBSubmit: xxx ...

  2. 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[]; ][ ...

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

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

  4. Codeforces Round #487 (Div. 2)

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

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

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

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

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

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

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

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

  9. Codeforces Round #278 (Div. 1) A. Fight the Monster 暴力

    A. Fight the Monster Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/487/ ...

随机推荐

  1. C语言实例解析精粹学习笔记——39(简单的文本编辑器)

    实例说明: 编辑一个简单的单行文本编辑器,编辑命令有以下几种:(E.Q.R.I.D) 只有自己在完全空白的情况下编写出来的程序,才是真正自己会的程序,现在所做的,不过是程序的搬运工,把书上的程序搬到网 ...

  2. "Mon Dec 31 00:00:00 CST 2012" java日期装换 "yyyy-MM-dd"

    import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import ja ...

  3. Go语言中的UDP应用

    Go语言中的UDP应用 Go语言中使用UDP是很方便的,net包提供了UDP和TCP的功能,这里使用UDP做了一个UDP广播,然后接收各个设备的返回信息.实现起来很快,总体感觉比使用C#中的UDP更优 ...

  4. PHP.40-TP框架商城应用实例-后台15-商品属性与库存量1-不同商品(唯一属性、可选属性),属性类型

    思路: 1.不同商品属于不同的类型,如:手机.服装.电脑等类型 2.不同的类型有不同的属性,其中分为唯一属性和可选属性,如服装:可选属性{尺寸:S,M,L……;颜色:白色,黑色……}唯一属性:材质 首 ...

  5. vue2018年5月报错No parser and no file path given

    mac电脑直接: rm -rf node_modules rm package-lock.json npm install npm install prettier@~1.12.1 执行完这四个命令, ...

  6. WPF中的数据模板(DataTemplate)

    原文:WPF中的数据模板(DataTemplate) WPF中的数据模板(DataTemplate)                                                   ...

  7. P3527 [POI2011]MET-Meteors

    P3527 [POI2011]MET-Meteors 链接 整体二分! 代码 #include<bits/stdc++.h> using namespace std; typedef lo ...

  8. Extjs报错:isField为空或不是对象

             在做Extjs开发的时候,有时候会碰到一个奇怪的问题,就是报错说"isField为空或不是对象",经过调试发现是一个数组,显示的长度是21,但是数组里面的个数只有 ...

  9. MyBatis实例教程--开发环境搭建

    MyBatis实例教程--开发环境搭建 准备工作: 1.mybatis 的开发环境搭建,选择: eclipse j2ee 版本,mysql 5.1 ,jdk 1.7,mybatis3.2.0.jar包 ...

  10. 父窗体和子窗体的显示,show&showdialog方法

    showdialog(): 子窗体弹出后,不能对父窗体进行操作.show()可以. 具体原理: 1.在调用Form.Show方法后,Show方法后面的代码会立即执行  2.在调用Form.ShowDi ...