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 ...
随机推荐
- 缺失dll的问题
不小心运行一下什么程序就会出现缺失xxx.dll的问题,太烦了,遇到好多,一直没有记录.现在开始记录,以便日后查看~ 1. api-ms-win-crt-runtime-l1-1-0.dll 64位系 ...
- Confluence 6 开始使用
欢迎来到 Confluence 的开始使用指南文档.在这个稳定中,你将会找到有关对 Confluence 进行评估的指南和其他的一些有用的内容.当你开始使用 Confluence 的时候,这些信息能够 ...
- Confluence 6 配置 HTTP 超时设置
当宏,例如 RSS Macro 进行 HTTP 请求的时候,有可能因为请求的时间比较长,而导致超时.你可以通过设置系统参数来避免这个问题. 配置 HTTP 超时设置: 在屏幕的右上角单击 控制台按钮 ...
- 【Windows】添加定时任务不执行
[问题]windows定时任务不执行.在“所有程序->附件->系统工具->任务计划程序”中添加了定时调用“D:\sys_task\bugmanager\run.bat”脚本的任务计划 ...
- React-Native到0.44版本后Navigator 不能用的问题
新升级 到0.46版本以后 Navigator 不能使用报错. 'Navigator is deprecated and has been removed from this package. It ...
- Tomcat解决中文乱码并部署项目
1.在Tomcat下的server.xml中添加URIEncoding="UTF-8"(解决中文乱码的问题) 2.在Tomcat下的server.xml中添加<Context ...
- LeetCode(120):三角形最小路径和
Medium! 题目描述: 给定一个三角形,找出自顶向下的最小路径和.每一步只能移动到下一行中相邻的结点上. 例如,给定三角形: [ [2], [3,4], [6,5,7], [4,1,8,3] ] ...
- (批量更新)对多个符合条件的id做更新操作
需求描述:把checkbox勾选的对应id的记录的标志位置1或0,这个其实不难的,不过我自己做的话,肯定是多次访问数据库做更新,看了老大的代码,发现差距不是一般的大,老大把sql灵活运用,结果一次访问 ...
- 【sqli-labs】Less1~Less4
学习sql注入啦,一下都是我做sqli-labs时的笔记.可能有错误,如果有人发现了欢迎指正~~ 常用知识点: 1.mysql注释有三种:① #: 注释从#到行尾 ② --空格: 注释到行尾,注意-- ...
- laravel 容器注入的坑
今天遍历添加数据时遇到个坑,哪位大神知道什么原因?? 起初的代码是这样的:(部分) public function addActive(Request $request, Activenorms $a ...