A. Black-and-White Cube
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given a cube of size k × k × k, which consists of unit cubes. Two unit cubes are considered neighbouring, if they have common face.

Your task is to paint each of k3 unit cubes one of two colours (black or white), so that the following conditions must be satisfied:

  • each white cube has exactly 2 neighbouring cubes of white color;
  • each black cube has exactly 2 neighbouring cubes of black color.
Input

The first line contains integer k (1 ≤ k ≤ 100), which is size of the cube.

Output

Print -1 if there is no solution. Otherwise, print the required painting of the cube consequently by layers. Print ak × k matrix in the firstk lines, showing how the first layer of the cube should be painted. In the followingk lines print ak × k matrix — the way the second layer should be painted. And so on to the lastk-th layer. Note that orientation of the cube in the space does not matter.

Mark a white unit cube with symbol "w" and a black one with "b". Use the format of output data, given in the test samples. You may print extra empty lines, they will be ignored.

Sample test(s)
Input
1
Output
-1
Input
2
Output
bb
ww bb
ww

题目意思,输出一个k*k*k的立体模型,使每个b的旁边有2个b,每个k的旁边有2个k
题解:

题目说的输出描述有点问题,它说的是先输出你的第1层,再输出k层从1到k的你的模型。实际上只用输出你构造的模型的1-k层。

这里提供两种构造方法

第1种

bbwwbb

bbwwbb

wwbbww

wwbbww

bbwwbb

bbwwbb

这种就是4个4个的。。以后每层就把上一层取反就OK了

还有一种是

bbbbbb

bwwwwb

bwbbwb

bwbbwb

bwwwwb

bbbbbb

类似这种不断将最外层围起来的构造方式,同理,以后的每层就把上一层取反就OK了。。

构造方法不唯一的。

至于 k 为奇数时无解我无法证明这个。。。

/*
* @author ipqhjjybj
* @date 20130709
*
*/
#include <cstdio>
#include <cstdlib> int main(){
int k;
scanf("%d",&k);
if(k&1) {
puts("-1");
return 0;
}
for(int i=0;i<k;i++){
for(int j=0;j<k;j++){
for(int z=0;z<k;z++){
putchar(((j>>1)&1)^((z>>1)&1)^(i&1)?'w':'b');
}
putchar('\n');
}
putchar('\n');
}
return 0;
}

cf 323A A. Black-and-White Cube 立体构造 不知道为什么当k为奇数时构造不出来 挺有趣的题目吧的更多相关文章

  1. cf 323A A. Black-and-White Cube 立体构造

    A. Black-and-White Cube time limit per test 1 second memory limit per test 256 megabytes input stand ...

  2. codeforces 323A. Black-and-White Cube 构造

    输入n 1 <= n <= 100 有一个n * n * n 的立方体,由n ^ 3 个1 * 1 * 1 的单位立方体构成 要用white 和 black 2种颜色来染这n ^ 3个立方 ...

  3. CF Good Bye 2018

    前言:这次比赛爆炸,比赛时各种想多,导致写到\(D\)题时思路已经乱了,肝了\(1\)个多小时都没肝出来,\(B\)题中途因为没开\(long\ long\)又被\(HACK\)了..\(C\)题因为 ...

  4. CF数据结构练习

    1. CF 438D The Child and Sequence 大意: n元素序列, m个操作: 1,询问区间和. 2,区间对m取模. 3,单点修改 维护最大值, 取模时暴力对所有>m的数取 ...

  5. CF 1025C Plasticine zebra

    昨晚忘记判只有一个字符的情况fst了呜呜呜 挺有趣的题,昨晚连刚带猜弄出结论 考虑答案的取值,最优答案可能是一个后缀,或者是一个前缀,或者是一个后缀加上前缀 那么翻转之后最优答案的可选值就有了1的前缀 ...

  6. WPF中制作立体效果的文字或LOGO图形

    原文:WPF中制作立体效果的文字或LOGO图形 较久之前,我曾写过一篇:"WPF绘制党徽(立体效果,Cool) "的博文.有感兴趣的朋友来EMAIL问是怎么制作的?本文解决此类问题 ...

  7. 【cf比赛记录】Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)

    比赛传送门 只能说当晚状态不佳吧,有点头疼感冒的症状.也跟脑子没转过来有关系,A题最后一步爆搜没能立即想出来,B题搜索没有用好STL,C题也因为前面两题弄崩了心态,最后,果然掉分了. A:简单数学 B ...

  8. 记人生中第一场认真打的CF——CF1000(虽然是Virtual participation)

    老师说下午要让我们(来自开明的新高一同学)感受一下CF,于是下午2:20我们就集中到了机房.老师教我们用Educational Codeforces Round 46 (Rated for Div. ...

  9. CF 题目选做

    写省选的题目对noip没什么大用 关键是 细节题或者是思考题比较重要 练思维自然是CF比较好了 把我见到的比较好的CF题放上来刷一刷. LINK:Complete the projects 就是说一个 ...

随机推荐

  1. 新手sqlserver数据库dba需要注意的小细节

    前言:任何的优化和修改都是以业务情况为前提,可能有的写的有误或者不准确的地方,欢迎各位来拍砖. 1.在创建db的时候自增长建议设置成按MB(M)增长,步长根据业务量来设置,一般情况建议设置100-20 ...

  2. jQuery库(noConflict)冲突解决机制

    很多JSFramework库选择使用$符号作为一个函数或变量名,而在实际的项目开发,模板语言,则有可能"$"符号是模板语言keyword.例如Veclocity模板语言,$它是ke ...

  3. JDK动态代理机制

    JDK Proxy OverView jdk的动态代理是基于接口的.必须实现了某一个或多个随意接口才干够被代理.并且仅仅有这些接口中的方法会被代理. 看了一下jdk带的动态代理api,发现没有样例实在 ...

  4. Asp.Net MVC路由调试好帮手RouteDebugger

    Asp.Net MVC路由调试好帮手RouteDebugger 1.获取方式 第一种方法: 在程序包控制台中执行命令 PM> Install-Package routedebugger 安装成功 ...

  5. jQuery实现表格行的动态增加与删除

    删除之前删除2行后: 1<script> 8 $(document).ready(function(){ 9 //<tr/>居中 10 $("#tab tr" ...

  6. python向mysql中存储JSON及Nodejs取出

    虽然把JSON数据存入mysql也是比较蛋疼,但是相比使用Nodejs嵌套处理多个mysql查询并拼接返回数据也算是没mongo时的一个折中方案了. 我使用python拼接了一个json格式的字符串, ...

  7. 11g R2RAC Dynamic remastering

    In this post, I will demonstrate dynamic remastering of the resources in RAC . In RAC, every data bl ...

  8. ubuntu新内核不能用启动回滚到旧内核的方法

    先看一看自己电脑上有哪些内核文件 merlin@tfAnalysis:~$ dpkg --get-selections|grep linux libselinux1:i386 install linu ...

  9. FFT 的C 语言

    FFT 的C 语言 说好的C 语言实现.必须搞定它! 理论介绍: http://blog.csdn.net/cinmyheart/article/details/39052739 这里有之前matla ...

  10. Scala是一门现代的多范式编程语言

    Scala是一门现代的多范式编程语言 Scala是一门现代的多范式编程语言,志在以简练.优雅及类型安全的方式来表达常用编程模式.它平滑地集成了面向对象和函数语言的特性. Scala是面向对象的:Sca ...