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. Asp.Net MVC5入门学习系列③

    原文:Asp.Net MVC5入门学习系列③ 添加一个视图(View) 接着上篇的入门系列,上面解说添加一个简单Controller(控制器),这里我们简单的在来添加一个View(视图)来展示我们Co ...

  2. C语言库函数大全及应用实例十四

    原文:C语言库函数大全及应用实例十四                                       [编程资料]C语言库函数大全及应用实例十四 函数名: strset 功 能: 将一个串 ...

  3. Mongodb操作之查询(循序渐进对比SQL语句)

    工具推荐:Robomongo,可自行百度寻找下载源,个人比较推荐这个工具,相比较mongoVUE则更加灵活. 集合简单查询方法 mongodb语法:db.collection.find()  //co ...

  4. jmeter java请求

    demo下载地址http://yun.baidu.com/share/link?shareid=4277735898&uk=925574576 1.引用jmeter的jar包 到jmeter的 ...

  5. Java开发工具IntelliJ IDEA使用教程:创建新的Andriod项目

    IntelliJ IDEA社区版作为一个轻量级的Java开发IDE,本身是一个开箱即用的Android开发工具. 注意:在本次的教程中我们将以Android平台2.2为例进行IntelliJ IDEA ...

  6. 【Android开发日记】妙用 RelativeLayout 实现3 段布局

    在设计过程中,我们经常会遇到这样的需求: 把一条线3控制,左对齐左控制,右侧控制右对齐,中间控制,以填补剩余空间. 或者一列内放3个控件,上面的与顶部对齐,以下的沉在最底部,中间控件是弹性的.充满剩余 ...

  7. android 首开机会在数据链接图标的状态栏打开并自行消失主动

    请找到该文件ConnectivityService.java (alps\frameworks\base\services\java\com\android\server)  在connectivit ...

  8. iOS基础 - 核心动画

    一.核心动画 l 核心动画基本概念 l 基本动画 l 关键帧动画 l 动画组 l 转场动画 l Core Animation是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事 ...

  9. Fiddler工具

    Fiddler初探 我们知道监视Http和Https请求的工具有多种,例如:HttpWatch,FireBug等.但是今天接触到一种新的工具Fiddler.Fiddler能记录所有客户端和服务器的ht ...

  10. GMap.Net

    GMap.Net开发之在WinForm和WPF中使用GMap.Net地图插件   GMap.NET是什么? 来看看它的官方说明:GMap.NET is great and Powerful, Free ...