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. 设计模式——模版方法模式详解(论沉迷LOL对学生的危害)

    .  实例介绍 在本例中,我们使用一个常见的场景,我们每个人都上了很多年学,中学大学硕士,有的人天生就是个天才,中学毕业就会微积分,因此得了诺贝尔数学奖:也有的人在大学里学了很多东西,过得很充实很满意 ...

  2. Android开发——View动画、帧动画和属性动画详解

    0. 前言   Android动画是面试的时候经常被问到的话题.我们都知道Android动画分为三类:View动画.帧动画和属性动画. 先对这三种动画做一个概述: View动画是一种渐进式动画,通过图 ...

  3. 程序在Linux下前后台切换

    程序在Linux下前后台切换 一.为什么要使程序在后台执行 背景:SecureCRT远程连接到linux主机,使程序在后台运行有以下好处: (1)本机关机不影响linux主机运行 (2)不影响计算效率 ...

  4. .NET基础知识之八——深拷贝,浅拷贝

    目录 1.概念 2.使用赋值符号"=" 3.浅复制 4.深复制 5.问题一:如果类里面嵌套有多个类,然后嵌套类里面又嵌套类,那么像上面实现深拷贝的方法还能用吗? 6.问题二:实现深 ...

  5. LeetCode题目解答

    LeetCode题目解答——Easy部分 Posted on 2014 年 11 月 3 日 by 四火 [Updated on 9/22/2017] 如今回头看来,里面很多做法都不是最佳的,有的从复 ...

  6. NSOperation那点事儿

    1. NSOperation.NSOperationQueue 简介 NSOperation.NSOperationQueue 是苹果提供给我们的一套多线程解决方案.实际上 NSOperation.N ...

  7. OpenCV入门:(三:图片Mask operations)

    Mask operations 翻译为中文应该是掩模操作,具体操作步骤就是根据一个操作矩阵(又名kernel)处理图片中的每一个像素点,操作矩阵会根据当前像素点的周围像素来调整当前像素值. 1.示例 ...

  8. Django admin源码剖析

    单例模式 单例模式(Singleton Pattern)是一种常用的软件设计模式,该模式的主要目的是确保某一个类只有一个实例存在.当你希望在整个系统中,某个类只能出现一个实例时,单例对象就能派上用场. ...

  9. 使用Vue-cli 3.x搭建Vue项目

    一.Vue-cli 3.x安装 Node 版本要求:Vue CLI 需要 Node.js 8.9 或更高版本 (推荐 8.11.0+) npm install -g @vue/cli 查版本是否正确 ...

  10. Spark搭档Elasticsearch

    Spark与elasticsearch结合使用是一种常用的场景,小编在这里整理了一些Spark与ES结合使用的方法.一. write data to elasticsearch利用elasticsea ...