题意:

让你构造一个 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. 普通平衡树 Splay

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

  2. Vue2实例中的data属性三种写法与作用

    <script src="https://unpkg.com/vue/dist/vue.js"></script> <div id="app ...

  3. elasticsearch多种搜索方式

    简要 1.query string search2.query DSL3.query filter4.full-text search5.phrase search6.highlight search ...

  4. 【BZOJ3600】没有人的算术 - 替罪羊树+线段树

    题意: 题解: Orz vfleaking……真·神题 做法大概是先把题意中定义的“数”都赋一个实数权值,用平衡树来维护整个从大到小排序过的序列,再用线段树查询最值: 这样做为什么是对的?考虑插入一个 ...

  5. Scalable Web Architecture and Distributed Systems

    转自:http://aosabook.org/en/distsys.html Scalable Web Architecture and Distributed Systems Kate Matsud ...

  6. 理解 Javascript 执行上下文和执行栈

    如果你是一名 JavaScript 开发者,或者想要成为一名 JavaScript 开发者,那么你必须知道 JavaScript 程序内部的执行机制.理解执行上下文和执行栈同样有助于理解其他的 Jav ...

  7. jenkins 自动化部署

    Execute shell Command BUILD_ID=DONTKILLMEif [ ! -d "/usr/jenkins/$JOB_NAME" ]; then mkdir ...

  8. Spring自带字符编码过滤器

    http://blog.csdn.net/youngage/article/details/51356821 http://blog.csdn.net/daelly/article/details/5 ...

  9. gem update --system

    gem update --system 修改完gem sources之后,进行gem update: gem update --system 之后的输出: C:\Sites\test01>gem ...

  10. BZOJ 2435: [Noi2011]道路修建 dfs搜图

    2435: [Noi2011]道路修建 Description 在 W 星球上有 n 个国家.为了各自国家的经济发展,他们决定在各个国家之间建设双向道路使得国家之间连通.但是每个国家的国王都很吝啬,他 ...