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. JavaScript实现判断图片是否加载完成的3种方法整理

    JavaScript实现判断图片是否加载完成的3种方法整理 有时候我们在前端开发工作中为了获取图片的信息,需要在图片加载完成后才可以正确的获取到图片的大小尺寸,并且执行相应的回调函数使图片产生某种显示 ...

  2. [Codeforces888E]Maximum Subsequence(暴力+meet-in-the-middle)

    题意:给定n.m.有n个数,选出若干数加起来对m取模,求最大值 n<=35 如果直接暴力就是235,会T, 这里用到一个思想叫meet-in-the-middle, 就是把数列分成两半分别搜索, ...

  3. ABAP CDS - Syntax

    The syntax of the DDL and of the DCL of the ABAP CDS comprises elements of the general DDL and DCL o ...

  4. The Road to learn React书籍学习笔记(第四章)

    高级React组件 本章将重点介绍高级 React 组件的实现.我们将了解什么是高阶组件以及如何实现它们.此外,我们还将深入探讨 React 中更高级的主题,并用它实现复杂的交互功能. 引用 DOM ...

  5. MySQL 从入门到删库

    基本操作 登陆指令 mysql -u用户名 -p密码(可以非明文输入) -h主机/IP -D端口 --prompt 提示符 修改提示符 \D 日期 \d 当前数据库 \h 服务器名 \u 用户名 // ...

  6. Grok Debugger本地安装(转载)

    原文链接:http://fengwan.blog.51cto.com/508652/1758845 最近在使用ELK对日志进行集中管理,因为涉及到日志的规则经常要用到http://grokdebug. ...

  7. kafka单机部署文档

    单机Kafka部署文档 最简单的使用方式,单机,使用自带的zookeeper 1.解压 下载地址:http://pan.baidu.com/s/1i4K2pXr tar –zxvf kafka_2.1 ...

  8. C#中Equals和= =(等于号)的比较)(转载)

    C#中Equals和= =(等于号)的比较) 相信很多人都搞不清Equals和 = =的区别,只是零星的懂一点,现在就让我带大家来进行一些剖析 一.           值类型的比较 对于值类型来说  ...

  9. Android——搜索传统蓝牙设备

    一,主布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:andro ...

  10. Hibernate-ORM:12.Hibernate中的多对多关联关系

    ------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 本篇博客将讲述Hibernate中的多对多关联关系的操作,准备的篇幅较少,望海涵 一,讲述多对多 多对多的关联 ...