Codeforces 989C - A Mist of Florescence
传送门:http://codeforces.com/contest/989/problem/C
这是一个构造问题。
构造一张网格,网格中的字符为’A’、’B’、’C’、’D’,并且其连通块的个数分别为a、b、c、d。
首先我们可以考虑两种颜色的情形:
构造一张网格,网格中的字符为’0’、’1’,并且其连通块的个数分别为a、b,其中a、b均为正整数。于是,至少为’0’、’1’分别构造一个连通块;再分别以连通块为“网”,植入’1’、’0’,植入时应保证植入的点互不连通。如下图所示:

以上构造法可以推广至四种颜色的情况。如下图所示:

参考程序如下:
#include <bits/stdc++.h>
using namespace std; char g[][]; int main(void)
{
int a, b, c, d;
cin >> a >> b >> c >> d;
cout << << " " << << endl;
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) g[i][j] = 'A';
for (int j = ; j < ; j++) g[i][j] = 'B';
}
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) g[i][j] = 'C';
for (int j = ; j < ; j++) g[i][j] = 'D';
}
a--; b--; c--; d--;
int x, y;
x = ; y = ;
while (d) {
g[x][y] = 'D';
y += ;
if (y >= ) {
y = ;
x += ;
}
d--;
}
x = ; y = ;
while (c) {
g[x][y] = 'C';
y+= ;
if (y >= ) {
y = ;
x += ;
}
c--;
}
x = ; y = ;
while (b) {
g[x][y] = 'B';
y += ;
if (y >= ) {
y = ;
x += ;
}
b--;
}
x = ; y = ;
while (a) {
g[x][y] = 'A';
y += ;
if (y >= ) {
y = ;
x += ;
}
a--;
}
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) putchar(g[i][j]);
putchar('\n');
}
}
Codeforces 989C - A Mist of Florescence的更多相关文章
- 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[]; ][ ...
- 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 ...
- 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\) 四种颜色来对矩形进行涂色使它满足要求 ...
- 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 构造 思维好题 第八题
A Mist of Florescence time limit per test 1 second memory limit per test 256 megabytes input standar ...
- 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 ...
- A Mist of Florescence CodeForces - 989C(思维构造)
题意: 让你构造一个图,使得A,B,C,D的个数为给定的个数,上下左右连通的算一个. 哎呀 看看代码就懂了..emm..很好懂的 #include <bits/stdc++.h> usin ...
随机推荐
- JeePlus:代码生成器-生成示例(操作)
ylbtech-JeePlus:代码生成器-生成示例(操作) 1.返回顶部 1. 生成示例由以下部分组成 单表 主附表 树表 富文本 图片管理 自定义树组件 自定义Grid 多对多 左树右表 2. 2 ...
- bzoj4868
http://www.lydsy.com/JudgeOnline/problem.php?id=4868 三分+贪心 我们可以知道这是一个单峰函数 当A>B那么我们每次调整一个的价钱是最佳的,所 ...
- c#自定义ORM框架---(泛型&反射&实体类扩展属性<附带通用增、删、查、改>)
该教材主要是运用到泛型.反射和实体类扩展属性 步骤一.建立扩展属性类 实体类扩展属性要继承Attribute基类完成 [AttributeUsage(AttributeTargets.Property ...
- [C陷阱和缺陷] 第7章 可移植性缺陷
C语言在许多不同的系统平台上都有实现.的确,使用C语言编写程序的一个首要原因就是,C程序能够方便地在不同的编程环境中移植. 不同的系统有不同的需求,因此我们应该能够预料到,机器不同则其上的C语 ...
- 国内使用pip / pip with GFW / pip 镜像
sudo pip install -i https://pypi.doubanio.com/simple/ YOUR_PACKAGE_NAME --trusted-host pypi.doubanio ...
- layer父页获取弹出层输入框里面的值
主要是因为修改功能,原来页面填写数据如图 改为 其中点击填写明细弹出框 填写完毕后点击确认返回,同事这里因为她是存的多表,所以点击确认就直接保存数据了,改的这个功能原本保存是整体保存,我就不想改原来的 ...
- Mui使用jquery并且使用点击跳转新窗口
网上好多朋友是这样做的: 全局插入了js代码 mui('body').on('tap', 'a', function () { document.location.href = this.href; ...
- Hadoop的数据采集框架
问题导读: Hadoop数据采集框架都有哪些? Hadoop数据采集框架异同及适用场景? Hadoop提供了一个高度容错的分布式存储系统,帮助我们实现集中式的数据分析和数据共享.在日常应用中我们比如要 ...
- jQuery实现文字横向滚动效果
HTML代码: <div id="aaa" style="width:100px; position:relative; white-space:nowrap; o ...
- [ HDOJ 3826 ] Squarefree number
\(\\\) \(Description\) \(T\)组数据,每次给出一个正整数 \(N\) ,判断其是否能被任意一个完全平方数整除. \(T\le 20,N\le 10^{18}\) \(\\\) ...