Storage box

0.55 Professor Oak has a storage box of size h × w × ℓ (hight, width and
length) in his garden. Although he is currently storing some soil and
fertilizer in it, he secretly plans to use it to hide the ashes of the
corpses of the students that he will catch cheating in the future. He
already has a large number of small boxes for the ashes, all of size
3 × 2 × 1. Note that each small box can be considered as the union of
six 1 × 1 × 1 cubes.

Given h, w and ℓ, can you tell if it is possible to completely fill the
storage box with small boxes? We can arrange each small box inside the
storage box in any direction parallel to the three dimensional axes.

Moreover, if it is possible to fill the storage box, can you provide a
way?

0.40 [image]

[image]

Input

Input consists of several cases, each with h, w and ℓ, all natural
numbers. You can assume 1 ≤ h × w × ℓ ≤ 10⁵.

Output

For each case, if it is impossible to fill the storage box, just print
“NO”. Otherwise, print “YES” and h ⋅ (w + 1) lines as follows: Assign a
different number between 1 and 10⁵ to each small box, and print it
exactly six times to describe the positions of the six 1 × 1 × 1 cubes
of the box. Each of the h levels of the storage box must be described
with w lines, each with ℓ numbers. An additional line with 10 dashes
ends each level. If there is more than one solution, you can print any
one. Follow strictly the format of the sample output.

For instance, to the left of the fifth sample output for a box with
heigth 3, width 2 and length 4 you can see a picture of the given
solution.

[image]

Problem information

Author: Salvador Roura
Event: Vint-i-quatrè Concurs de Programació de la UPC - Semifinal
Date: 2026-06-18

Generation: 2026-06-10T18:39:54.658Z

© Jutge.org, 2006–2026.
https://jutge.org
