CF989C A Mist of Florescence 构造 思维好题 第八题
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.

题意: 给你A,B,C,D连通量的数目(连通量指上或下或左或右有连接),要你给出一个矩阵(给出的矩阵长宽小于等于50)满足这样的要求
引入别人博客的一张图
图中说明了一切 将你的矩阵四分,分别填充B,A,D,C,然后在这四个矩阵中按要求填充
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(a) cout << #a << " " << a << endl
using namespace std;
const int maxn = 1e2 + ;
const int mod = 1e9 + ;
typedef long long ll;
char mapn[maxn][maxn];
void myfill( ll xs, ll ys, ll xe, ll ye, char c ) {
for( ll i = xs; i <= xe; i ++ ) {
for( ll j = ys; j <= ye; j ++ ) {
mapn[i][j] = c;
}
}
}
int main(){
std::ios::sync_with_stdio(false);
ll a, b, c, d;
while( cin >> a >> b >> c >> d ) {
a --, b --, c --, d --;
myfill( , , , , 'B' );
myfill( , , , , 'A' );
myfill( , , , , 'D' );
myfill( , , , , 'C' );
for( ll i = ; i <= ; i ++ ) {
for( ll j = ; j <= ; j ++ ) {
if( i % && j % && a ) {
mapn[i][j] = 'A';
a --;
}
}
}
for( ll i = ; i <= ; i ++ ) {
for( ll j = ; j <= ; j ++ ) {
if( i % == && j % == && b ) {
mapn[i][j] = 'B';
b --;
}
}
}
for( ll i = ; i <= ; i ++ ) {
for( ll j = ; j <= ; j ++ ) {
if( i % && j % && c ) {
mapn[i][j] = 'C';
c --;
}
}
}
for( ll i = ; i <= ; i ++ ) {
for( ll j = ; j <= ; j ++ ) {
if( i % == && j % == && d ) {
mapn[i][j] = 'D';
d --;
}
}
}
cout << "50 50" << endl;
for( ll i = ; i <= ; i ++ ) {
cout << mapn[i] << endl;
}
}
return ;
}
CF989C A Mist of Florescence 构造 思维好题 第八题的更多相关文章
- CF989C A Mist of Florescence 构造
		
正解:构造 解题报告: 先放传送门yep! 然后构造题我就都直接港正解了QwQ没什么可扯的QwQ 这题的话,首先这么想吼 如果我现在构造的是个4*4的 举个栗子 AABB ACBB AADB DBCA ...
 - CF989C A Mist of Florescence (构造)
		
CF989C A Mist of Florescence solution: 作为一道构造题,这题确实十分符合构造的一些通性----(我们需要找到一些规律,然后无脑循环).个人认为这题规律很巧妙也很典 ...
 - 【题解】CF989C A Mist of Florescence
		
[题解]CF989C A Mist of Florescence 题目大意: 让你构造一个\(n∗m\)矩阵,这个矩阵由4种字符填充构成,给定4个整数,即矩阵中每种字符构成的四联通块个数,\(n,m\ ...
 - CF989C A Mist of Florescence
		
思路: 有趣的构造题. 实现: #include <bits/stdc++.h> using namespace std; ][]; void fillin(int x, int y, c ...
 - Codeforces Round #487 (Div. 2) C. A Mist of Florescence 构造
		
题意: 让你构造一个 n∗mn*mn∗m 矩阵,这个矩阵由 444 种字符填充构成,给定 444 个整数,即矩阵中每种字符构成的联通块个数,n,mn,mn,m 需要你自己定,但是不能超过505050. ...
 - CF989C A Mist of Florescence 题解
		
因为 \(1 \leq a,b,c,d \leq 100\) 所以每一个颜色都有属于自己的联通块. 考虑 \(a = b=c=d=1\) 的情况. AAAAAAAAAAAAAAAAAAAAAAAAAA ...
 - CF思维联系– Codeforces-989C C. A Mist of Florescence
		
ACM思维题训练集合 C. A Mist of Florescence time limit per test 1 second memory limit per test 256 megabytes ...
 - 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 A Mist of Florescence
		
A Mist of Florescence 题目大意: 事先告诉你每种颜色分别有几个联通块,构造一个不超过 \(50*50\) 的矩形.用 \(A,B,C,D\) 四种颜色来对矩形进行涂色使它满足要求 ...
 
随机推荐
- OI/ACM最全卡常大招
			
NO.10: 循环展开: 在缓存和寄存器允许的情况下一条语句内大量的展开运算会刺激 CPU 并发(蛤?这是个什么原理,算了,反正写了没坏处就这么写吧) NO.9: 特殊运算优化:(或许这真的没用) 取 ...
 - DesignPattern系列__02接口隔离原则
			
介绍 客户端不应该依赖它不需要的接口,即一个类对另一个类的依赖应该建立在最小接口上. Demo引入 先来看一张图: interface MyInterface { void operation1(); ...
 - kali Metasploit 连接 Postgresql 默认密码
			
使用 metasploit 时, 1. 启动 postgresql service postgresql start 2. 自行测试 postgresql 是否安装成功 根据需要,自行 修改 post ...
 - (十)c#Winform自定义控件-横向列表
			
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...
 - java之面向对象详解
			
#############java面向对象详解#############1.面向对象基本概念2.类与对象3.类和对象的定义格式4.对象与内存分析5.封装性6.构造方法7.this关键字8.值传递与引用 ...
 - Unable to load template file 'rj\ThinkPHP/Tpl/dispatch_jump.tpl'----thinkphp3.2.3
			
Unable to load template file 'rj\ThinkPHP/Tpl/dispatch_jump.tpl'----thinkphp3.2.3 1.报错原因:将thinkphp默认 ...
 - Go_ go mod 命令解决墙的问题
			
简介 由于众所周知的原因,在下载一些库的时候会下载不了,比如 golang.org/x/... 相关的库.为此,网上出现了很多解决方案. 从 Go1.11 开始,Go 引入了 module,对包进行管 ...
 - 关于Js debounce 函数小结
			
一.前言 以下场景往往由于事件频繁被触发,因而频繁执行DOM操作.资源加载等重行为,导致UI停顿甚至浏览器崩溃. 1. window对象的resize.scroll事件 2. 拖拽时的mousemov ...
 - 多线程之pthread, NSThread, NSOperation, GCD
			
关于多线程会有一系列如下:多线程之概念解析 多线程之pthread, NSThread, NSOperation, GCD 多线程之NSThread 多线程之NSOperation 多线程之GCD p ...
 - Cat应用告警实战
			
1. Cat应用告警实战 1.1. 前言 好像是中间件设计者的通病,文档写的都是面向有一定使用各种中间件经验的人,告警模块中每个参数其实都可以详细解释一下,要不然我们理解起来真的很吃力还容易采坑 1. ...