Codeforces Round #487 (Div. 2) C. A Mist of Florescence 构造
题意:
让你构造一个 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 构造的更多相关文章
- 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[]; ][ ...
- Codeforces Round #487 (Div. 2)
A. A Blend of Springtime(暴力/模拟) 题目大意 给出$n$个花,每个点都有自己的颜色,问是否存在连续大于等于三个花颜色均不相同 sol 直接模拟判断即可 #include&l ...
- 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 ...
- 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 ...
- Codeforces Round #487 (Div. 2) 跌分有感
又掉分了 这次的笑话多了. 首先,由于CF昨天的比赛太早了,忘记了有个ER,比赛开始半个小时才发现. 于是只能今天了. 嗯哈. 今天这场也算挺早的. 嗯嗯,首先打开A题. 草草看了一遍题意,以为不是自 ...
- Codeforces Round #487 (Div. 2) E. A Trance of Nightfall (矩阵优化)
题意 有一个平面 , 给你 \(n\) 个点构成一个点集 \(S\) , 一开始可以选择一个平面上任意点 \(P\) . 存在一种操作 : 1 选择一条至少 通过 \(S\) 中任意两个点以及 \(P ...
- Codeforces Round #292 (Div. 1)A. Drazil and Factorial 构造
A. Drazil and Factorial 题目连接: http://codeforces.com/contest/516/problem/A Description Drazil is play ...
- 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 ...
随机推荐
- Aeroplane chess HDU - 4405_数学期望_逆推
Code: #include<cstdio> #include<algorithm> #include<cstring> using namespace std; ...
- selenium工作原理
在我们new一个webdriver过程中 selenium会检测本地浏览器组件是否存在,版本是否匹配,接着会启动一套webservice ,这套webservice使用的selenium定义的webw ...
- sessionStorage与clone方法在项目中的应用
//资料列表: //JSON.parse(jsonstr); //json格式字符串转换成json对象 //JSON.stringify(jsonobj); //json对象转换成json格式字符串 ...
- 【hiho一下第二周 】Trie树
[题目链接]:http://hihocoder.com/problemset/problem/1014 [题意] [题解] 在字典树的域里面加一个信息cnt; 表示这个节点下面,记录有多少个单词; 在 ...
- 模仿学习小游戏外星人入侵-Python学习,体会“函数”编程
游戏类如下: # !/usr/bin/python # -*- coding:utf-8 -*- """ Author :ZFH File :alien.py Softw ...
- BA--关于江森的学习笔记
机房功率密度:“每机架”功耗 数据中心效率:平均 PUE 2.5,百度是1.36,苹果是1.06 绿色数据中心:PUE<1.58 机房环境:空气质量,配电,UPS,空气处理系统,发电机,江森OD ...
- [ASP.NET]EF选一个空表的情况
public List<DAL.StuFillAnswers> FillsToCheck(int sid,int eid) { using (DAL.ExamSysEntities db ...
- HDU 3709
真是跪了,一看范围就不会往枚举的方向想,没想到真用枚举加剪枝了...->——-> 解释一下代码中的上限: 例如4567,当枚举最高位时,很明显不能超过4,所以有上限,但当最高位为3以下时, ...
- “System.IO.FileNotFoundException”类型的未经处理的异常在 mscorlib.dll 中发生
这个错误是我在打包的时候.发现的,由于我移动了我的project的位置(从C盘移动到了D盘),看一下出错的代码: Dim strDB As String = System.Configuration. ...
- SSH学习之中的一个 OpenSSH基本使用
在Linux系统中.OpenSSH是眼下最流行的远程系统登录与文件传输应用,也是传统Telenet.FTP和R系列等网络应用的换代产品. 当中,ssh(Secure Shell)能够替代telnet. ...