Problem B. Black and White Gym-100801B] 想象力
来源:互联网 发布:mac重装没有磁盘 编辑:程序博客网 时间:2024/06/05 03:19
Problem B. Black and White
原题文档:https://odzkskevi.qnssl.com/f8fd72d9900eebaf15d7ea41975a6532?v=1501122426
Input le:
black.in
Output le:
black.out
Time limit:
2 seconds
Memory limit:
256 megabytes
The jury has a great artistic idea | to create a rectangular panel out of a huge pile of black and white
squares of the same size. The panel should have exactly
b
4-connected areas made of black tiles, and
w
4-connected areas made of white tiles.
Remember, a
4-connected area
of some color is a maximal set of the panel tiles such that:
any two tiles of the area share the same color;
for any two tiles of the area there is a tile sequence connecting them, such that any two consecutive
tiles of the sequence share a common side.
In addition to the artistic idea, the jury has already developed a program that produces design of the
panel. But since this problem is about art, any new solution is extremely important for the jury.
Input
The only line of the input le contains two integers
b
and
w
| number of black and white areas
(1
b; w
1000).
Output
The rst line of the output le should contain the picture sizes
r
and
c
| the number of rows and columns
(1
r; c
100 000). This line should be followed by
r
lines of
c
symbols each. Each symbol should be
either
@
' (for black tile) or
.
’ (for white one). There should be no more than 100 000 tiles in the panel.
Example
black.in
2 3
black.out
6 7
@@@@@@@
@.@@@@@
@@…@@
@@@@@@@
…….
@@@@@@@
这个。。。考验的是想象力?
1.上边五百行 下边五百行 跳着填充
#include <iostream>#include <cstring>#include <cstdlib>#include <cstdio>using namespace std;const int maxn = 1e3+5;char s[maxn][105];int main(){ int i, j;// freopen("black.in","r",stdin);// freopen("black.out","w",stdout); int b, w; while(cin>>b>>w) { --b;--w; for(i = 0; i < 500;i++) { for(j = 0; j<100;j++) s[i][j] = '@'; } for(i = 500; i<1000;i++) { for(j=0;j<100;j++) s[i][j] = '.'; } for(i=0;i<500&&w;i+=2) { for(j=0;j<100&&w;j+=2) { --w;s[i][j] = '.'; } } for(i=501;i<1000&&b;i+=2) { for(j=0;j<100&&b;j+=2) { --b;s[i][j]='@'; } } printf("1000 100\n"); for(i=0;i<1000;i++) { for(j=0;j<100;j++) printf("%c",s[i][j]); printf("\n"); } puts(""); } return 0;}
2.
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;int main(){ int n,m; char c[2] = {'.','@'}; //freopen("black.in","r",stdin); //freopen("black.out","w",stdout); scanf("%d%d",&n,&m); if(n > m) { std::swap(n,m); std::swap(c[0],c[1]); } printf("%d %d\n",2*m,3); for(int i = 0;i < (m-n);i ++)//用多的把少的圈起来 { printf("%c%c%c\n%c%c%c\n",c[1],c[1],c[1],c[1],c[0],c[1]); } for(int i = 0;i < n;i ++)//当黑白要求一样时不断间隔输出,各一行! { printf("%c%c%c\n%c%c%c\n",c[1],c[1],c[1],c[0],c[0],c[0]); } return 0;}
- Problem B. Black and White Gym-100801B] 想象力
- B - Red and Black
- 内部赛3 B Black and white painti…
- 2014北京赛区现场赛B hdu 5113 Black And White
- Hdu 5113 Black and White ---2014北京现场赛B题
- HDU 5113 Black And White(2014ACM/ICPC北京赛区B)
- hdu5113 贪心搜索 2014ACM/ICPC亚洲区北京站 B题 Black And White
- Codeforces Gym 100623B Problem B. Billboard
- Round B APAC Test 2017 Problem B. Sherlock and Watson Gym Secrets
- Problem B. Sherlock and Watson Gym Secrets Google APAC 2017 University Test Round B
- B - Red and Black+dfs
- Red and Black(HDU1312)(B)
- Black And White
- Black And White
- Black and white hdu3633
- hdu3911 Black And White
- hdu3911---Black And White
- HDU5113 Black And White
- c语言之单链表
- python中需要注意的一些地方
- ubuntu安装/更新cudnn版本遇到的问题
- ReentrantReadWriteLock类源代码分析
- Java抽象类和接口
- Problem B. Black and White Gym-100801B] 想象力
- Python初入门(一)(Head First Python 第一章 初识Python)
- Linux 管理网络
- Linux常用命令
- 今天是上班的第三天,以后的路还很长,记录一下个人的成长,本人屌丝程序猿一个
- 杭电1008坐电梯
- SQL经典题目
- Codeforces Round #425 (Div. 2) D. Misha, Grisha and Underground LCA
- HDU