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. 在amazon linux上安装Jenkins

    原文请参考: https://medium.com/@itsmattburgess/installing-jenkins-on-amazon-linux-16aaa02c369c

  2. mybatis 打印SQL

    如果使用的是application.properties文件,加入如下配置: #打印SQL logging.level.com.jn.ssr.supererscuereporting.dao=debu ...

  3. 阿里云mysql连接不上

    轻量级服务器管理 - 防火墙 - 添加规则 防火墙 mysql 3306 注意IPtables 与 firewalld 状态! 啃爹的防火墙,找了一天

  4. 解决 Python2 和 Python3 的共存问题

    首先安装两种版本的Python 进入系统属性更改环境变量 将两个版本的安装路径找出. 添加至PATH中,变量之间用分号隔开. D:\Python36\Scripts\;D:\Python36\;D:\ ...

  5. Go语言的标准net库使用

    Go语言的标准net库使用 与大多数语言一样,Go的标准库是很全的,因为Go的出现本来就是为了网络通信的高并发实现,所以其相关的网络库封装得很简洁,也更加的易读.这里对使用到的api进行记录. net ...

  6. Hive 函数之内置运算符

    本章介绍Hive的内置运算符.在Hive有四种类型的运算符: 关系运算符 算术运算符 逻辑运算符 复杂运算符 关系运算符 这些操作符被用来比较两个操作数.下表描述了在Hive中可用的关系运算符: 运算 ...

  7. Python正则表达式中的re.S,re.M,re.I的作用

    正则表达式可以包含一些可选标志修饰符来控制匹配的模式.修饰符被指定为一个可选的标志.多个标志可以通过按位 OR(|) 它们来指定.如 re.I | re.M 被设置成 I 和 M 标志: 修饰符 描述 ...

  8. IdFTP中FEAT命令的问题

    IdFTP控件很方便开发FTP客户端,用于传输文件.一次笔者的一个在阿里云的服务器突发故障,显示无法登陆FTP,而使用其他客户端(如FlashFxp)经过该项目设置,又可正常使用. 查询后说是FEAT ...

  9. Ubuntu16.04安装Zabbix

    基于Zabbix+MySQL+Apache(可选) apt-get install php7.0-bcmath php7.0-xml php7.0-mbstring安装Zabbix所需的几个PHP模块 ...

  10. 图的同构 (Graph Isomorphism)

    整理摘自:https://www.jianshu.com/p/c33b5d1b4cd9 同构是在数学对象之间定义的一类映射,它能揭示出在这些对象的属性或者操作之间存在的关系.若这两个数学结构之间存在同 ...