codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

323A.md (1430B)


      1 Source: https://codeforces.com/problemset/problem/323/A
      2 
      3 A. Black-and-White Cube
      4 
      5 time limit per test
      6 
      7 0.5 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 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.
     22 
     23 Your task is to paint each of *k*3 unit cubes one of two colours (black or white), so that the following conditions must be satisfied:
     24 
     25 * each white cube has exactly 2 neighbouring cubes of white color;
     26 * each black cube has exactly 2 neighbouring cubes of black color.
     27 
     28 Input
     29 
     30 The first line contains integer *k* (1 ≤ *k* ≤ 100), which is size of the cube.
     31 
     32 Output
     33 
     34 Print -1 if there is no solution. Otherwise, print the required painting of the cube consequently by layers. Print a *k* × *k* matrix in the first *k* lines, showing how the first layer of the cube should be painted. In the following *k* lines print a *k* × *k* matrix — the way the second layer should be painted. And so on to the last *k*-th layer. Note that orientation of the cube in the space does not matter.
     35 
     36 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.
     37 
     38 Examples
     39 
     40 Input
     41 
     42 ```
     43 1
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 -1
     50 ```
     51 
     52 Input
     53 
     54 ```
     55 2
     56 ```
     57 
     58 Output
     59 
     60 ```
     61 bb  
     62 ww  
     63   
     64 bb  
     65 ww
     66 ```