题意:

让你构造一个 n∗mn*mn∗m 矩阵,这个矩阵由 444 种字符填充构成,给定 444 个整数,即矩阵中每种字符构成的联通块个数,n,mn,mn,m 需要你自己定,但是不能超过505050.

数据范围:

每个字符组成的联通块个数不超过100.

题解:

正着生成联通块似乎有些费劲,不如我们逆着思考问题将400个联通块生成,并逐渐减少联通块的个数。

A picture is worth a thousand words



任意发挥想象吧!

Code:

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 100;
char str[maxn][maxn];
inline void init()
{
for(int i = 1;i <= 25; ++i)
for(int j = 1;j <= 25; ++j) str[i][j] = 'B';
for(int i = 1;i <= 25; ++i)
for(int j = 26;j <= 50;++j) str[i][j] = 'A'; for(int i = 26;i <= 50; ++i)
for(int j = 1;j <= 25; ++j) str[i][j] = 'C';
for(int i = 26;i <= 50; ++i)
for(int j = 26;j <= 50; ++j) str[i][j] = 'D';
int cnt = 0;
for(int i = 2;i < 25; i += 2)
{
for(int j = 2;j < 25; j += 2)
{
if(cnt >= 99) break;
++cnt;
str[i][j] = 'A';
}
}
cnt = 0;
for(int i = 2;i < 25; i += 2)
{
for(int j = 27;j < 50;j += 2)
{
if(cnt >= 99) break;
++cnt;
str[i][j] = 'B';
}
}
cnt = 0;
for(int i = 27;i < 50;i += 2)
for(int j = 2;j < 25; j += 2)
{
if(cnt >= 99) break;
++cnt;
str[i][j] = 'D';
}
cnt = 0;
for(int i = 27;i < 50;i += 2)
for(int j = 27;j < 50;j += 2)
{
if(cnt >= 99) break;
++cnt;
str[i][j] = 'C';
} }
int main()
{
//freopen("input.in","r",stdin);
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
printf("50 50\n");
init();
a = 100 - a, b = 100 - b, c = 100 - c, d = 100 - d;
int cnt_a = 0, cnt_b = 0, cnt_c = 0, cnt_d = 0;
for(int i = 2;i < 25; i += 2)
for(int j = 2;j < 25; j += 2)
{
if(cnt_a >= a) break;
++cnt_a;
str[i][j] = 'B';
}
for(int i = 2;i < 25; i += 2)
for(int j = 27;j < 50;j += 2)
{
if(cnt_b >= b) break;
++cnt_b;
str[i][j] = 'A';
}
for(int i = 27;i < 50;i += 2)
for(int j = 2;j < 25; j += 2)
{
if(cnt_d >= d) break;
++cnt_d;
str[i][j] = 'C';
}
for(int i = 27;i < 50;i += 2)
for(int j = 27;j < 50;j += 2)
{
if(cnt_c >= c) break;
++cnt_c;
str[i][j] = 'D';
}
for(int i = 1;i <= 50; ++i)
{
for(int j = 1;j <= 50; ++j) printf("%c",str[i][j]);
printf("\n");
}
return 0; }

Codeforces Round #487 (Div. 2) C. 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. Codeforces Round #487 (Div. 2)

    A. A Blend of Springtime(暴力/模拟) 题目大意 给出$n$个花,每个点都有自己的颜色,问是否存在连续大于等于三个花颜色均不相同 sol 直接模拟判断即可 #include&l ...

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

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

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

  6. Codeforces Round #487 (Div. 2) 跌分有感

    又掉分了 这次的笑话多了. 首先,由于CF昨天的比赛太早了,忘记了有个ER,比赛开始半个小时才发现. 于是只能今天了. 嗯哈. 今天这场也算挺早的. 嗯嗯,首先打开A题. 草草看了一遍题意,以为不是自 ...

  7. Codeforces Round #487 (Div. 2) E. A Trance of Nightfall (矩阵优化)

    题意 有一个平面 , 给你 \(n\) 个点构成一个点集 \(S\) , 一开始可以选择一个平面上任意点 \(P\) . 存在一种操作 : 1 选择一条至少 通过 \(S\) 中任意两个点以及 \(P ...

  8. Codeforces Round #292 (Div. 1)A. Drazil and Factorial 构造

    A. Drazil and Factorial 题目连接: http://codeforces.com/contest/516/problem/A Description Drazil is play ...

  9. Codeforces Round #228 (Div. 1) B. Fox and Minimal path 构造

    B. Fox and Minimal path 题目连接: http://codeforces.com/contest/388/problem/B Description Fox Ciel wants ...

随机推荐

  1. JS 猴子

    公园里有一只猴子和一堆桃子,猴子每天吃掉桃子总数的一半,把剩下一半中扔掉一个坏的. 到第七天的时候,猴子睁开眼发现只剩下一个桃子.问公园里刚开始有多少个桃子? <!DOCTYPE html> ...

  2. git 教程1

    一. git简介 1.1 git是什么? 是一个分布式版本控制软件 1.2 git的作用是什么? 版本控制 ,团队协作 1.3 git的优势在哪里? 同类型的版本控制软件:CVS及SVN,Linus一 ...

  3. nginx (待更新)

    install apt install nginx 默认在 /etc/nginx 目录下 一个 master 以及多个 worker 3504 root 20 0 141M 7196 5552 S 0 ...

  4. C语言基础 (5) 常用操作符

    01 课程回顾 变量的起名:字母数字下划线 不能是关键字 常量 变量提升:老的编译器这样会报错 运算符:sizeof.+.-.x … … 进制: 1111 8421 计算机几乎都是二进制系统,而且是以 ...

  5. 多行文本省略号样式失效丢失,以及控制台显示autoprefixer警告'Autoprefixer applies control comment to whole block, not to next rules.'

    问题现象   使用webpack压缩打包vue项目,遇到一个问题,文本多行显示省略号的关键css语句-webkit-box-orient: vertical;莫名其妙丢失失效了.查阅资料,有不少人提出 ...

  6. apache https部署

    1.生成证书,直接在阿里云或腾讯云中生成此处不再介绍 2.在httpd.conf中取消#LoadModule ssl_module modules/mod_ssl.so的注释 3.开启httpd-ss ...

  7. 在android平台打印C语言日志

    在android平台打印C语言日志 1.操作平台:AS2.0 2.步骤如下: 在C代码中添加如下代码: #define LOG_TAG "我的C语言日志:" #define LOG ...

  8. LightOJ1214 Large Division

    /* LightOJ1214 Large Division http://lightoj.com/login_main.php?url=volume_showproblem.php?problem=1 ...

  9. BA-风阀水阀执行器接线图

    220水阀执行器接线图 24V风阀执行器接线图

  10. oracle 解除锁表sql

    select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_objects b where b ...