C. A Mist of Florescence ----- Codeforces Round #487 (Div. 2)
1 second
256 megabytes
standard input
standard output
"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.
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.
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).
5 3 2 1
4 7
DDDDDDD
DABACAD
DBABACD
DDDDDDD
50 50 1 1
4 50
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
ABABABABABABABABABABABABABABABABABABABABABABABABAB
BABABABABABABABABABABABABABABABABABABABABABABABABA
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
1 6 4 5
7 7
DDDDDDD
DDDBDBD
DDCDCDD
DBDADBD
DDCDCDD
DBDBDDD
DDDDDDD
In the first example, each cell of Amaranths, Begonias and Centaureas forms a connected component, while all the Dianthuses form one.
嗯 就是一开始把50*50染成四种颜色,然后分别往里面塞不同颜色的块,这样就可以保证,在原有的块是1的情况下,一个一个的加,
当然要注意 每次行要+=2,列也要+=2,防止他们联通成一个,最后需要注意最后一列填充的时候,不要和他旁边的块联通;
一种方法是把D 填充到 A 的区域 这样对着填充,另外也可以不要从第一列开始往后+,从第二列,这样第25列就不会填充了(即每行最多12个)。
每种颜色最多有100个。
所以每个块最多可以放数量12*12的其他颜色而不影响它自己的连通性。
#include<iostream>
#include<cstdio>
#define For(i,a,b,num) for(int i=a; i<b&&num>0; i+=2)
using namespace std; char maps[][]; void paint(int sx,int sy,char word)
{
for(int i=sx; i<sx+; ++i){
for(int j=sy; j<sy+; ++j){
maps[i][j] = word;
}
}
} int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
paint(,,'A');
paint(,,'B');
paint(,,'C');
paint(,,'D');
a--,b--,c--,d--;
For(i,,,d){
For(j,,,d){
maps[i][j] = 'D';
d--;
}
}
For(i,,,c){
For(j,,,c){
maps[i][j] = 'C';
c--;
}
}
For(i,,,b){
For(j,,,b){
maps[i][j] = 'B';
b--;
}
}
For(i,,,a){
For(j,,,a){
maps[i][j] = 'A';
a--;
}
}
printf("50 50\n");
for(int i=; i<; ++i){
for(int j=; j<; ++j){
printf("%c",*(maps[i]+j));
}
puts("");
}
}
C. A Mist of Florescence ----- Codeforces Round #487 (Div. 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[]; ][ ...
- 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 ...
- Codeforces Round #487 (Div. 2)
A. A Blend of Springtime(暴力/模拟) 题目大意 给出$n$个花,每个点都有自己的颜色,问是否存在连续大于等于三个花颜色均不相同 sol 直接模拟判断即可 #include&l ...
- 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 ...
- Codeforces Round #487 (Div. 2) C. A Mist of Florescence 构造
题意: 让你构造一个 n∗mn*mn∗m 矩阵,这个矩阵由 444 种字符填充构成,给定 444 个整数,即矩阵中每种字符构成的联通块个数,n,mn,mn,m 需要你自己定,但是不能超过505050. ...
- Codeforces Round #487 (Div. 2) 跌分有感
又掉分了 这次的笑话多了. 首先,由于CF昨天的比赛太早了,忘记了有个ER,比赛开始半个小时才发现. 于是只能今天了. 嗯哈. 今天这场也算挺早的. 嗯嗯,首先打开A题. 草草看了一遍题意,以为不是自 ...
- Codeforces Round #487 (Div. 2) E. A Trance of Nightfall (矩阵优化)
题意 有一个平面 , 给你 \(n\) 个点构成一个点集 \(S\) , 一开始可以选择一个平面上任意点 \(P\) . 存在一种操作 : 1 选择一条至少 通过 \(S\) 中任意两个点以及 \(P ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- 一种基于NTC的控温电路及软件实现
NTC(Negative Temperature Coefficient)是一种随温度上升时,电阻值呈指数关系减小的热敏电阻.应用广泛,最近我们就采用了NTC来控制加热并测温,并达到了预期的效果. 1 ...
- 【MySql】Group By数据分组
GROUP BY 语句根据一个或多个列对结果集进行分组. 在分组的列上我们可以使用 COUNT, SUM, AVG,等函数. 因为聚合函数通过作用于一组数据而只返回一个单个值, 因此,在SELECT语 ...
- Confluence 6 配置数据库查询超时时间
如果数据库的查询时间太长同时你的应用程序显示没有响应,你可以配置数据库的查询超时时间.在默认情况下 Confluence 没有超时时间.希望配置数据库查询超时时间,在你的测试服务器上进行下面的操作: ...
- linux之iptables常用命令
iptables详解 iptables -L 该命令会以列表的形式显示出当前使用的 iptables 规则,每一条规则前面的编号可以用来做为其它操作--例如删除操作--的参数,很有用 iptables ...
- Java与C++&C语言的个人看法----异同点(A)
日期:2018.7.30 星期一 博客期:004 第四期的博客我来说一下自己对Java的看法以及它与C++有什么异同之处! 先说不同之处吧!Java应该说是更面向对象一点,它的Java包里类可以通过用 ...
- 补充的flask实例化参数以及信号
一.实例化补充 instance_path和instance_relative_config是配合来用的.这两个参数是用来找配置文件的,当用app.config.from_pyfile('settin ...
- PyCharm+SVN
首先电脑安装svn,并且确svn/bin下面有svn.exe文件 没有bin/svn.exe解决方法: 重新打开TortoiseSVN安装文件-Modify-Next后在command line cl ...
- Windows安装MongoDB
一.简介 MongoDB 是一个基于分布式 文件存储的NoSQL数据库 由C++语言编写,运行稳定,性能高 旨在为 WEB 应用提供可扩展的高性能数据存储解决方案 查看官方网站 MongoDB特点 模 ...
- Python内置模块之time模块
1:概述 时间表示的分类 时间戳 格式化的时间字符串 结构化时间 时间戳:时间戳表示的是从1970年1月1日整0点到目前秒的偏移量,数据类型是浮点型,主要用来让计算机看的 格式化的时间字符串:如 20 ...
- 饮冰三年-人工智能-linux-08 软件包管理(Python的安装)
1:软件包存放的位置 media/CentOS_6.9_Final/Packages文件夹下 2.RPM就是Red Hat Package Manger(红帽软件包管理工具)的缩写. 2.1 常用的命 ...