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 first k lines, showing how the first layer of the cube should be painted. In the followingk lines print a k × 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 立体构造的更多相关文章

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

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

  2. CF 633 div1 1338 B. Edge Weight Assignment 构造

    LINK:Edge Weight Assignment 这场当时没打 看到这个B题吓到我了 还好当时没打. 想了20min才知道怎么做 而且还不能证明. 首先考虑求最小. 可以发现 如果任意两个叶子节 ...

  3. CF 453C. Little Pony and Summer Sun Celebration

    CF 453C. Little Pony and Summer Sun Celebration 构造题. 题目大意,给定一个无向图,每个点必须被指定的奇数或者偶数次,求一条满足条件的路径(长度不超\( ...

  4. electrica writeup

    关于 caesum.com 网上上的题目,分类有Sokoban,Ciphers,Maths,Executables,Programming,Steganography,Misc.题目有点难度,在努力奋 ...

  5. Android 轮播图Banner切换图片的效果

    Android XBanner使用详解 2018年03月14日 08:19:59 AND_Devil 阅读数:910   版权声明:本文为博主原创文章,未经博主允许不得转载. https://www. ...

  6. Unity3D Shader 入门

    什么是Shader Shader(着色器)是一段能够针对3D对象进行操作.并被GPU所执行的程序,它负责将输入的Mesh(网格)以指定的方式和输入的贴图或者颜色等组合作用,然后输出.绘图单元可以依据这 ...

  7. Unity3D学习笔记(三十四):Shader着色器(1)

    一.GPU:图形处理器,Graphics Processing Unit 显卡的处理器就是图形处理器.与CPU类似.   GPU和CPU的区别? 1.CPU主要是为了串行指令设计,GPU则是为了大规模 ...

  8. 棋盘覆盖问题(算法分析)(Java版)

    1.问题描述: 在一个2k×2k个方格组成的棋盘中,若有一个方格与其他方格不同,则称该方格为一特殊方格,且称该棋盘为一个特殊棋盘.显然特殊方格在棋盘上出现的位置有种情形.因而对任何 k≥0,有4k种不 ...

  9. Unity Shader基础

    Unity Shader基础 先上代码,代码一般是这样的. void Initialization(){ //先从硬盘加载代码再加载到GPU中 string vertexShaderCode = Lo ...

随机推荐

  1. 真正理解javascript的五道题目.

    题目一: if (!("a" in window)) { var a = 1; } alert(a); 题目二: var a = 1, b = function a(x) { x ...

  2. win32 字体变换与窗口同大同小

    #include <windows.h> #include "res/resource.h" LRESULT CALLBACK WinProc(HWND hwnd, U ...

  3. Could not find or load main class

    Then add '.' to your $CLASSPATH with CLASSPATH=.:$CLASSPATH or as a paramater with java -classpath . ...

  4. 网络数据(socket)传输总结

    环境限定:TCP/IP下的socket网络传输:C/C++开发语言,32/64位机. 目前有两种方式对数据进行传输:1)字符流形式,即将数据用字符串表示:2)结构型方式,即将数据按类型直接传输. 1) ...

  5. [Codecademy] HTML&CSS 第一课:HTML Basic

    本文出自   http://blog.csdn.net/shuangde800 ------------------------------------------------------------ ...

  6. 检测用户是否具有administrator权限(OpenThreadToken,OpenProcessToken,GetTokenInformation,AllocateAndInitializeSid和EqualSid)

    检测用户是否具有administrator权限const SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority = (Value: (0, 0, 0, 0, 0 ...

  7. 调整Tomcat的并发线程到5000+

    调整Tomcat的并发线程数到5000+ 1. 调整server.xml的配置 先调整maxThreads的数值,在未调整任何参数之前,默认的并发线程可以达到40. 调整此项后可以达到1800左右. ...

  8. Lua获取网络时间

    作者:ani_di  版权所有,转载务必保留此链接 http://blog.csdn.net/ani_di Lua获取网络时间 网络授时服务是一些网络上的时间服务器提供的时间,一般用于本地时钟同步. ...

  9. DELPHI学习---类和对象(五篇)

    Classes and objects(类和对象) 类(或者类类型)定义了一个结构,它包括字段(也称为域).方法和属性:类的实例叫做对象:类的字段.方法和属性被称为它的部件(components)或成 ...

  10. C++ STL中Map的相关排序操作:按Key排序和按Value排序 - 编程小径 - 博客频道 - CSDN.NET

    C++ STL中Map的相关排序操作:按Key排序和按Value排序 - 编程小径 - 博客频道 - CSDN.NET C++ STL中Map的相关排序操作:按Key排序和按Value排序 分类: C ...