Cover a square with rectangles P69283


Statement
 

pdf   zip

Suppose that you have an infinite suply of m×2mm \times 2m rectangles for every natural m1m \ge 1. You have to exactly cover an ×\ell \times \ell square (you can choose \ell ) by placing nn of those rectangles horizontally or vertically. For instance, these are some ways for n=2n = 2, n=5n = 5 and n=6n = 6:

(10,6)

(0,0)(0,1)(2,1)(2,0) (0,1)(0,2)(2,2)(2,1)

(4,0)(4,4)(6,4)(6,0) (6,0)(6,2)(7,2)(7,0) (7,0)(7,2)(8,2)(8,0) (6,3)(6,4)(8,4)(8,3) (6,2)(6,3)(8,3)(8,2)

(10,0)(10,4)(12,4)(12,0) (10,4)(10,6)(14,6)(14,4) (14,2)(14,6)(16,6)(16,2) (12,0)(12,2)(16,2)(16,0) (12,2)(12,3)(14,3)(14,2) (12,3)(12,4)(14,4)(14,3)

There are only a few nn for which it is impossible to cover a square with nn such rectangles. In particular, it is always possible when n%3=2n \% 3 = 2. Can you prove it?

Input

Input consists of several nn such that n2(mod3)n \equiv 2 \pmod{3}. Assume 2n622 \le n \le 62.

Output

For every nn, first print a line with an \ell between 2 and 30. Afterwards, print \ell lines with \ell characters each. Use different digits, lowercase letters and uppercase letters to indicate each rentangle. Since there are multiple possible solutions, print any one.

Public test cases
  • Input

    2
    2
    14
    

    Output

    2
    00
    11
    6
    ZZZaaa
    ZZZaaa
    ZZZaaa
    ZZZaaa
    ZZZaaa
    ZZZaaa
    8
    C3POjj42
    C3POdd42
    BBBBBBBB
    BBBBBBBB
    BBBBBBBB
    BBBBBBBB
    T1111XX5
    T1111YY5
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++