传送门: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的更多相关文章

  1. 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[]; ][ ...

  2. 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 ...

  3. 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 ...

  4. Codeforces A Mist of Florescence

    A Mist of Florescence 题目大意: 事先告诉你每种颜色分别有几个联通块,构造一个不超过 \(50*50\) 的矩形.用 \(A,B,C,D\) 四种颜色来对矩形进行涂色使它满足要求 ...

  5. CF989C A Mist of Florescence (构造)

    CF989C A Mist of Florescence solution: 作为一道构造题,这题确实十分符合构造的一些通性----(我们需要找到一些规律,然后无脑循环).个人认为这题规律很巧妙也很典 ...

  6. 【题解】CF989C A Mist of Florescence

    [题解]CF989C A Mist of Florescence 题目大意: 让你构造一个\(n∗m\)矩阵,这个矩阵由4种字符填充构成,给定4个整数,即矩阵中每种字符构成的四联通块个数,\(n,m\ ...

  7. CF989C A Mist of Florescence 构造 思维好题 第八题

    A Mist of Florescence time limit per test 1 second memory limit per test 256 megabytes input standar ...

  8. 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 ...

  9. A Mist of Florescence CodeForces - 989C(思维构造)

    题意: 让你构造一个图,使得A,B,C,D的个数为给定的个数,上下左右连通的算一个. 哎呀 看看代码就懂了..emm..很好懂的 #include <bits/stdc++.h> usin ...

随机推荐

  1. RDA 多屏参流程

    一.RDA MAKEFILE的本地变量 在介绍多屏参之前,先看一下./code/env.conf的包含过程,通过./code/Makefile.project加载,env.conf中所有的变量,都变为 ...

  2. 杂项-Java:FreeMarker

    ylbtech-杂项-Java:FreeMarker 1.返回顶部 1. FreeMarker是一款模板引擎: 即一种基于模板和要改变的数据, 并用来生成输出文本(HTML网页.电子邮件.配置文件.源 ...

  3. MySQL:MySQL安装

    ylbtech-MySQL:MySQL安装 mysql5.5.27_win64_zol.msi 1.返回顶部 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14 ...

  4. 使用Java实现图像分割

    为减少动画制作过程中的IO操作,我们可以使用连续动画来改善动画播放效率.如果我们对图像中的每张小图像单独分割成独立的文件,那么当每次要使用这些小图像的时候,我们都得从文件中读取图像信息. 实际上我们可 ...

  5. is not mapped [from错误

    我出现的错误是:org.hibernate.hql.ast.QuerySyntaxException: loginuser is not mapped [from loginuser] 配置文件如下: ...

  6. 栗染-Not enough physical memory is available to power on this virtual machine with its configured settings.

    这是在打开虚拟机的时候报的错 解决办法:打开虚拟机的时候选择以管理员身份运行()目测可以 原文参考来自:http://blog.csdn.net/qq_35757415/article/details ...

  7. AtCoder Regular Contest 099 C~E

    C - Minimization 枚举就可以了 因为最后一定会变成1,所以第一次操作的区间就包含1会比较优,然后枚举1在第一次操作区间里排第几个取min即可 #include<iostream& ...

  8. justify-content属性

    justify-content 用于设置或检索弹性盒子元素在主轴方向上的对齐方式. 属性值:flex-start 属性值:flex-end 属性值:center 属性值:space-between 属 ...

  9. Nginx(二) 反向代理&负载均衡

    1.反向代理 当我们请求一个网站时,nginx会决定由哪台服务器提供服务,就是反向代理. nginx只做请求的转发,后台有多个tomcat服务器提供服务,nginx的功能就是把请求转发给后面的服务器, ...

  10. git clone ssh permissions are too open 解决方案。

    错误如图所示 方案如下 https://stackoverflow.com/questions/9270734/ssh-permissions-are-too-open-error