Codeforces Round #487 (Div. 2) A Mist of Florescence (暴力构造)
1 second
256 megabytes
standard input
standard output
"I've been here once," Mino exclaims with delight, "it's breathtakingly amazing."
"What is it like?"
"Look, Kanno, you've got your paintbrush, and I've got my words. Have a try, shall we?"
There are four kinds of flowers in the wood, Amaranths, Begonias, Centaureas and Dianthuses.
The wood can be represented by a rectangular grid of nn rows and mm columns. In each cell of the grid, there is exactly one type of flowers.
According to Mino, the numbers of connected components formed by each kind of flowers are aa, bb, cc and dd respectively. Two cells are considered in the same connected component if and only if a path exists between them that moves between cells sharing common edges and passes only through cells containing the same flowers.
You are to help Kanno depict such a grid of flowers, with nn and mm arbitrarily chosen under the constraints given below. It can be shown that at least one solution exists under the constraints of this problem.
Note that you can choose arbitrary nn and mm under the constraints below, they are not given in the input.
The first and only line of input contains four space-separated integers aa, bb, cc and dd (1≤a,b,c,d≤1001≤a,b,c,d≤100) — the required number of connected components of Amaranths, Begonias, Centaureas and Dianthuses, respectively.
In the first line, output two space-separated integers nn and mm (1≤n,m≤501≤n,m≤50) — the number of rows and the number of columns in the grid respectively.
Then output nn lines each consisting of mm consecutive English letters, representing one row of the grid. Each letter should be among 'A', 'B', 'C' and 'D', representing Amaranths, Begonias, Centaureas and Dianthuses, respectively.
In case there are multiple solutions, print any. You can output each letter in either case (upper or lower).
5 3 2 1
4 7
DDDDDDD
DABACAD
DBABACD
DDDDDDD
50 50 1 1
4 50
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
ABABABABABABABABABABABABABABABABABABABABABABABABAB
BABABABABABABABABABABABABABABABABABABABABABABABABA
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
1 6 4 5
7 7
DDDDDDD
DDDBDBD
DDCDCDD
DBDADBD
DDCDCDD
DBDBDDD
DDDDDDD
In the first example, each cell of Amaranths, Begonias and Centaureas forms a connected component, while all the Dianthuses form one.
你们看代码吧 !这题简直超级无脑,超级暴力,然而我还写不出 !!!我太菜了我菜爆了
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
typedef long long LL;
const int maxn = 3e5 + ; char tu[][];
int num[];
int dx[] = {, , , -};
int dy[] = {, -, , };
int check(int i, int j ) {
if (i < || i >= || j < || j >= ) return ;
return ;
}
int check1(int i, int j, char cnt ) {
for (int k = ; k < ; k++) {
int nx = i + dx[k];
int ny = j + dy[k];
// printf("%c %c\n",tu[nx][ny],cnt);
if (check(nx, ny)) {
if (tu[nx][ny] == cnt) return ;
}
}
return ;
}
int main() {
char s[] = "ABCD";
scanf("%d%d%d%d", &num[], &num[], &num[], &num[]);
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) {
if (i < && j < ) tu[i][j] = 'A';
if (i < && j >= ) tu[i][j] = 'B';
if (i >= && j < ) tu[i][j] = 'C';
if (i >= && j >= ) tu[i][j] = 'D';
}
}
if (num[] - ) {
int cnt = ;
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) {
if (i >= && j >= ) {
int sum = ;
for (int k = ; k < ; k++) {
if (tu[i - ][k] == 'A') sum++;
}
if (sum > ) break;
if (tu[i][j] == 'D' && check1(i, j, s[] ) ) {
tu[i][j] = 'A';
cnt++;
}
if (cnt == num[]) break;
}
}
if (cnt == num[]) break;
}
}
if (num[] - ) {
int cnt = ;
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) {
if (i >= && j < ) {
int sum = ;
for (int k = ; k < ; k++) {
if (tu[i - ][k] == 'B') sum++;
}
if (sum > ) break;
if (tu[i][j] == 'C' && check1(i, j, s[]) ) {
tu[i][j] = 'B';
cnt++;
}
}
if (cnt == num[]) break;
}
if (cnt == num[]) break;
}
}
if (num[] - ) {
int cnt = ;
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) {
if (i < && j >= ) {
int sum = ;
for (int k = ; k < ; k++) {
if (tu[i - ][k] == 'C') sum++;
}
if (sum > ) break;
if (tu[i][j] == 'B' && check1(i, j, s[]) ) {
tu[i][j] = 'C';
cnt++;
}
}
if (cnt == num[]) break;
}
if (cnt == num[]) break;
}
}
if (num[] - ) {
int cnt = ;
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) {
if (i < && j < ) {
int sum = ;
for (int k = ; k < ; k++) {
if (tu[i - ][k] == 'D') sum++;
}
if (sum > ) break;
if (tu[i][j] == 'A' && check1(i, j, s[]) ) {
tu[i][j] = 'D';
cnt++;
}
}
if (cnt == num[]) break;
}
if (cnt == num[]) break;
}
}
printf("50 50\n");
for (int i = ; i < ; i++)
printf("%s\n", tu[i]);
return ;
}
View
Codeforces Round #487 (Div. 2) A Mist of Florescence (暴力构造)的更多相关文章
- Codeforces Round #297 (Div. 2)D. Arthur and Walls 暴力搜索
Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec Memory Limit: 512 MBSubmit: xxx ...
- 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[]; ][ ...
- 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. A Blend of Springtime(暴力/模拟) 题目大意 给出$n$个花,每个点都有自己的颜色,问是否存在连续大于等于三个花颜色均不相同 sol 直接模拟判断即可 #include&l ...
- 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) C. A Mist of Florescence 构造
题意: 让你构造一个 n∗mn*mn∗m 矩阵,这个矩阵由 444 种字符填充构成,给定 444 个整数,即矩阵中每种字符构成的联通块个数,n,mn,mn,m 需要你自己定,但是不能超过505050. ...
- 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 #278 (Div. 1) A. Fight the Monster 暴力
A. Fight the Monster Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/487/ ...
随机推荐
- 2018徐州网络赛H. Ryuji doesn't want to study
题目链接: https://nanti.jisuanke.com/t/31458 题解: 建立两个树状数组,第一个是,a[1]*n+a[2]*(n-1)....+a[n]*1;第二个是正常的a[1], ...
- SAN---第二网的概念
网络技术的优缺点:优点:连接能力,超强路由,管理能力,远距离缺点:低速以及高负载,强烈的软件需求,错误检测能力 SAN:storage area network(存储区域网络)--是一种基于光网的特殊 ...
- Lambda表达式详解【转】
前言 1.天真热,程序员活着不易,星期天,也要顶着火辣辣的太阳,总结这些东西. 2.夸夸lambda吧:简化了匿名委托的使用,让你让代码更加简洁,优雅.据说它是微软自c#1.0后新增的最重要的功能之一 ...
- 实用脚本 4 -- Makefile(不同文件下的多个可执行文件or静态库编译到同一目录下)
不同文件下的多个可执行文件编译到同一目录下,这样方便观察编译结果,从而方便进程操作.使用时根据自己的需要在进行局部修改(如 链接库.目标文件等等). 1..bashrc 中设置编译主目录(例如) ex ...
- 揭秘css
这是我看到非常好的一本电子教程,可以当参考手册使用,链接
- 虚拟现实-VR-UE4-创建第一个C++项目——Hello word
这部分主要是调用在C++中用代码实现在游戏界面上面输出一行文字 第一步,新建C++版本的工程文件,在4.12版本以后,在创建后,都会自动打开Vs编译器. 如下图 在VS中点击编译,等带编译,第一次等待 ...
- SPOJ 375 Query on a tree(树链剖分)(QTREE)
You are given a tree (an acyclic undirected connected graph) with N nodes, and edges numbered 1, 2, ...
- Python如何进行中文注释
最近,由于实习工作的需要,开始接触Python,但是第一个大的脚本写下来之后,连中文注释都没办法加,很郁闷,遂在网上找解决办法,在Python 官网上看到这个页面:http://www.python. ...
- 【转】 cocos2dx 3.x C++搭建protobuf环境
http://blog.csdn.net/ganpengjin1/article/details/50964961 Cocos2dx 里面在网络游戏通信这一块一般我们都会采用protobuf来进行通信 ...
- zuoyebiji