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. 有关doctype!!!

    浏览器呈现模式 现代浏览器包括不同的呈现模式,目的是既支持遵循标准的网页,也支持为老式浏览器而设计的网页.其中, Standards (标准)模式(也就是严格呈现模式)用于呈现遵循最新标准的网页,而 ...

  2. Monkey源码分析之事件源

    上一篇文章<Monkey源码分析之运行流程>给出了monkey运行的整个流程,让我们有一个概貌,那么往后的文章我们会尝试进一步的阐述相关的一些知识点. 这里先把整个monkey类的结构图给 ...

  3. MVC5+ 路由特性

    MVC5+ 路由特性 概述 ASP.NET MVC 5支持一种新的路由协议,称为路由特性. MVC5也支持以前定义路由的方式,你可以在一个项目中混合使用这两种方式来定义路由. 案例 1.使用Visua ...

  4. GDI+ 摘要: 保存图像文件

    要保存图像文件,必须先获得图像的编码格式信息.可是GDI+没有直接提供这个函数:GetEncoderClsid(const WCHAR* format, CLSID* pClsid) 因此须要我们自己 ...

  5. MyEclipse的真正价值——时间等于金钱

    全世界成千上万的Java开发者选择MyEclipse作为首选的Eclipse IDE,甚至超过了著名的开发工具 IBM Rational和Eclipse Java. 为什么? 很简单,MyEclips ...

  6. 使用Windows2003创建DNS服务器 - 进阶者系列 - 学习者系列文章

    Windows 2003的DNS服务器的配置还是比较简单的.下面简要介绍下DNS服务器的配置. 1.    打开控制面板,选择 添加删除Windows组件,选择 网络服务 ,选择 详细信息,选择 域名 ...

  7. HTTP 报文中的 Header 字段进行身份验证

    [小技巧][ASP.Net MVC Hack] 使用 HTTP 报文中的 Header 字段进行身份验证 在一些 Web 系统中,身份验证是依靠硬件证书进行的:在电脑上插入 USB 证书,浏览器插件读 ...

  8. Reporting Service部署之访问权限

    原文:Reporting Service部署之访问权限 SQL Server Reporting Services 并非专门设计用于 Internet 报表部署方案,但是您可以成功地将 Reporti ...

  9. Building Modern Web Apps-构建现代的 Web 应用程序

    Building Modern Web Apps-构建现代的 Web 应用程序 视频长度:1 小时左右 视频作者:Scott Hunter 和 Scott Hanselman 视频背景:Visual ...

  10. class 添加样式,删除,开关 【选择】addClass,removeClass,toggleClass

    <1> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>< ...