题意:

让你构造一个 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. 洛谷P2894 [USACO08FEB]酒店Hotel_区间更新_区间查询

    Code: #include<cstdio> #include<algorithm> #include<cstring> using namespace std; ...

  2. google spanner

    REF 论文 google spanner spanner 介绍 http://blog.jobbole.com/110262/

  3. Django入门--模型系统(一):模型基础

    1.Django的ORM介绍 对象关系映射(英语:(Object Relational Mapping,简称ORM,或O/RM,或O/R mapping),是一种程序技术,用于实现面向对象编程语言里不 ...

  4. 20190226-SecureCRT连接linux显示中文乱码

    SecureCRT连接我的Ubuntu14时中文显示乱码 解决办法: 在session options里选择UTF-8

  5. Docker学习总结(14)——从代码到上线, 云端Docker化持续交付实践

    2016云栖大会·北京峰会于8月9号在国家会议中心拉开帷幕,在云栖社区开发者技术专场中,来自阿里云技术专家罗晶(瑶靖)为在场的听众带来<从代码到上线,云端Docker化持续交付实践>精彩分 ...

  6. redis helloworld

    一.启动 redis 服务 [root@MyLinux bin]# ./redis-server redis.conf 二.使用客户端连接服务 [root@MyLinux bin]# ./redis- ...

  7. [Tailwind] Get started with Tailwindcss

    In this lesson, we learn how to generate CSS utility classes from Tailwind's JavaScript config file. ...

  8. C++数值类型极限值的获取

    C/C++中基本类型的数值极限值一般来说都是与详细平台有关的,在程序设计的过程中为了写出与平台无关的程序则必须通过合理科学的方法去获取各种类型的极值,经常使用的获取方法有两种:一种是传统的C语言所採用 ...

  9. android mvp高速开发框架介绍(dileber使用之图片下载工具)

    这几天忙着工作- 今天抽时间又把框架的bug处理了一下--并且把volley的源代码改动了一下 android mvp框架:dileber(https://github.com/dileber/dil ...

  10. 串口之CreateFile 函数具体解释

    HANDLE CreateFile( LPCTSTR lpFileName, //指向文件名称的指针 DWORD dwDesiredAccess, //訪问模式(写/读) DWORD dwShareM ...